TSK-1500: Enable compression by default (#3177)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2023-05-15 11:41:33 +07:00 committed by GitHub
parent 6423d1beeb
commit c41cc022c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 34 additions and 21 deletions

View File

@ -159,7 +159,7 @@ export async function configurePlatform() {
// Use binary response transfer for faster performance and small transfer sizes.
setMetadata(client.metadata.UseBinaryProtocol, true)
// Disable for now, since it causes performance issues on linux/docker/kubernetes boxes for now.
setMetadata(client.metadata.UseProtocolCompression, false)
setMetadata(client.metadata.UseProtocolCompression, true)
setMetadata(workbench.metadata.PlatformTitle, 'Platform')
}

View File

@ -1 +1 @@
{ "major": 0, "minor": 6, "patch": 93 }
{ "major": 0, "minor": 6, "patch": 95 }

View File

@ -25,6 +25,8 @@ const serverPort = parseInt(process.env.SERVER_PORT ?? '3333')
const serverFactory = serverFactories[(process.env.SERVER_PROVIDER as string) ?? 'ws'] ?? serverFactories.ws
const enableCompression = (process.env.ENABLE_COMPRESSION ?? 'true') === 'true'
const url = process.env.MONGO_URL
if (url === undefined) {
console.error('please provide mongodb url')
@ -92,7 +94,8 @@ const shutdown = start(url, {
serverFactory,
indexParallel: 2,
indexProcessing: 500,
productId: ''
productId: '',
enableCompression
})
const close = (): void => {

View File

@ -186,6 +186,8 @@ export function start (
indexProcessing: number // 1000
indexParallel: number // 2
enableCompression?: boolean
}
): () => Promise<void> {
addLocation(serverAttachmentId, () => import('@hcengineering/server-attachment-resources'))
@ -336,6 +338,7 @@ export function start (
sessionFactory,
port: opt.port,
productId: opt.productId,
serverFactory: opt.serverFactory
serverFactory: opt.serverFactory,
enableCompression: opt.enableCompression
})
}

View File

@ -155,7 +155,8 @@ export function start (
// fallback to standard filter function
return compression.filter(req, res)
}
},
level: 6
})
)
app.use(cors())

View File

@ -508,6 +508,7 @@ export function start (
sessionFactory: (token: Token, pipeline: Pipeline, broadcast: BroadcastCall) => Session
productId: string
serverFactory: ServerFactory
enableCompression?: boolean
}
): () => Promise<void> {
const sessions = new TSessionManager(ctx, opt.sessionFactory)
@ -517,6 +518,7 @@ export function start (
ctx,
opt.pipelineFactory,
opt.port,
opt.productId
opt.productId,
opt.enableCompression ?? true
)
}

View File

@ -33,25 +33,28 @@ export function startHttpServer (
ctx: MeasureContext,
pipelineFactory: PipelineFactory,
port: number,
productId: string
productId: string,
enableCompression: boolean
): () => Promise<void> {
if (LOGGING_ENABLED) console.log(`starting server on port ${port} ...`)
const wss = new WebSocketServer({
noServer: true,
perMessageDeflate: false,
// perMessageDeflate: {
// zlibDeflateOptions: {
// // See zlib defaults.
// chunkSize: 16 * 1024,
// level: 6
// },
// zlibInflateOptions: {
// chunkSize: 16 * 1024,
// level: 6
// },
// threshold: 1024 // Size (in bytes) below which messages, should not be compressed if context takeover is disabled.
// },
perMessageDeflate: enableCompression
? {
zlibDeflateOptions: {
// See zlib defaults.
chunkSize: 16 * 1024,
level: 6
},
zlibInflateOptions: {
chunkSize: 16 * 1024,
level: 6
},
threshold: 1024, // Size (in bytes) below which messages, should not be compressed if context takeover is disabled.
concurrencyLimit: 100
}
: false,
skipUTF8Validation: true
})
// eslint-disable-next-line @typescript-eslint/no-misused-promises

View File

@ -164,5 +164,6 @@ export type ServerFactory = (
ctx: MeasureContext,
pipelineFactory: PipelineFactory,
port: number,
productId: string
productId: string,
enableCompression: boolean
) => () => Promise<void>