mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-22 21:50:34 +03:00
TSK-1500: Enable compression by default (#3177)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
6423d1beeb
commit
c41cc022c5
@ -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')
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
{ "major": 0, "minor": 6, "patch": 93 }
|
||||
{ "major": 0, "minor": 6, "patch": 95 }
|
||||
|
@ -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 => {
|
||||
|
@ -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
|
||||
})
|
||||
}
|
||||
|
@ -155,7 +155,8 @@ export function start (
|
||||
|
||||
// fallback to standard filter function
|
||||
return compression.filter(req, res)
|
||||
}
|
||||
},
|
||||
level: 6
|
||||
})
|
||||
)
|
||||
app.use(cors())
|
||||
|
@ -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
|
||||
)
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -164,5 +164,6 @@ export type ServerFactory = (
|
||||
ctx: MeasureContext,
|
||||
pipelineFactory: PipelineFactory,
|
||||
port: number,
|
||||
productId: string
|
||||
productId: string,
|
||||
enableCompression: boolean
|
||||
) => () => Promise<void>
|
||||
|
Loading…
Reference in New Issue
Block a user