mirror of
https://github.com/hcengineering/platform.git
synced 2025-06-01 21:31:04 +00: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.
|
// Use binary response transfer for faster performance and small transfer sizes.
|
||||||
setMetadata(client.metadata.UseBinaryProtocol, true)
|
setMetadata(client.metadata.UseBinaryProtocol, true)
|
||||||
// Disable for now, since it causes performance issues on linux/docker/kubernetes boxes for now.
|
// 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')
|
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 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
|
const url = process.env.MONGO_URL
|
||||||
if (url === undefined) {
|
if (url === undefined) {
|
||||||
console.error('please provide mongodb url')
|
console.error('please provide mongodb url')
|
||||||
@ -92,7 +94,8 @@ const shutdown = start(url, {
|
|||||||
serverFactory,
|
serverFactory,
|
||||||
indexParallel: 2,
|
indexParallel: 2,
|
||||||
indexProcessing: 500,
|
indexProcessing: 500,
|
||||||
productId: ''
|
productId: '',
|
||||||
|
enableCompression
|
||||||
})
|
})
|
||||||
|
|
||||||
const close = (): void => {
|
const close = (): void => {
|
||||||
|
@ -186,6 +186,8 @@ export function start (
|
|||||||
|
|
||||||
indexProcessing: number // 1000
|
indexProcessing: number // 1000
|
||||||
indexParallel: number // 2
|
indexParallel: number // 2
|
||||||
|
|
||||||
|
enableCompression?: boolean
|
||||||
}
|
}
|
||||||
): () => Promise<void> {
|
): () => Promise<void> {
|
||||||
addLocation(serverAttachmentId, () => import('@hcengineering/server-attachment-resources'))
|
addLocation(serverAttachmentId, () => import('@hcengineering/server-attachment-resources'))
|
||||||
@ -336,6 +338,7 @@ export function start (
|
|||||||
sessionFactory,
|
sessionFactory,
|
||||||
port: opt.port,
|
port: opt.port,
|
||||||
productId: opt.productId,
|
productId: opt.productId,
|
||||||
serverFactory: opt.serverFactory
|
serverFactory: opt.serverFactory,
|
||||||
|
enableCompression: opt.enableCompression
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,8 @@ export function start (
|
|||||||
|
|
||||||
// fallback to standard filter function
|
// fallback to standard filter function
|
||||||
return compression.filter(req, res)
|
return compression.filter(req, res)
|
||||||
}
|
},
|
||||||
|
level: 6
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
app.use(cors())
|
app.use(cors())
|
||||||
|
@ -508,6 +508,7 @@ export function start (
|
|||||||
sessionFactory: (token: Token, pipeline: Pipeline, broadcast: BroadcastCall) => Session
|
sessionFactory: (token: Token, pipeline: Pipeline, broadcast: BroadcastCall) => Session
|
||||||
productId: string
|
productId: string
|
||||||
serverFactory: ServerFactory
|
serverFactory: ServerFactory
|
||||||
|
enableCompression?: boolean
|
||||||
}
|
}
|
||||||
): () => Promise<void> {
|
): () => Promise<void> {
|
||||||
const sessions = new TSessionManager(ctx, opt.sessionFactory)
|
const sessions = new TSessionManager(ctx, opt.sessionFactory)
|
||||||
@ -517,6 +518,7 @@ export function start (
|
|||||||
ctx,
|
ctx,
|
||||||
opt.pipelineFactory,
|
opt.pipelineFactory,
|
||||||
opt.port,
|
opt.port,
|
||||||
opt.productId
|
opt.productId,
|
||||||
|
opt.enableCompression ?? true
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -33,25 +33,28 @@ export function startHttpServer (
|
|||||||
ctx: MeasureContext,
|
ctx: MeasureContext,
|
||||||
pipelineFactory: PipelineFactory,
|
pipelineFactory: PipelineFactory,
|
||||||
port: number,
|
port: number,
|
||||||
productId: string
|
productId: string,
|
||||||
|
enableCompression: boolean
|
||||||
): () => Promise<void> {
|
): () => Promise<void> {
|
||||||
if (LOGGING_ENABLED) console.log(`starting server on port ${port} ...`)
|
if (LOGGING_ENABLED) console.log(`starting server on port ${port} ...`)
|
||||||
|
|
||||||
const wss = new WebSocketServer({
|
const wss = new WebSocketServer({
|
||||||
noServer: true,
|
noServer: true,
|
||||||
perMessageDeflate: false,
|
perMessageDeflate: enableCompression
|
||||||
// perMessageDeflate: {
|
? {
|
||||||
// zlibDeflateOptions: {
|
zlibDeflateOptions: {
|
||||||
// // See zlib defaults.
|
// See zlib defaults.
|
||||||
// chunkSize: 16 * 1024,
|
chunkSize: 16 * 1024,
|
||||||
// level: 6
|
level: 6
|
||||||
// },
|
},
|
||||||
// zlibInflateOptions: {
|
zlibInflateOptions: {
|
||||||
// chunkSize: 16 * 1024,
|
chunkSize: 16 * 1024,
|
||||||
// level: 6
|
level: 6
|
||||||
// },
|
},
|
||||||
// threshold: 1024 // Size (in bytes) below which messages, should not be compressed if context takeover is disabled.
|
threshold: 1024, // Size (in bytes) below which messages, should not be compressed if context takeover is disabled.
|
||||||
// },
|
concurrencyLimit: 100
|
||||||
|
}
|
||||||
|
: false,
|
||||||
skipUTF8Validation: true
|
skipUTF8Validation: true
|
||||||
})
|
})
|
||||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||||
|
@ -164,5 +164,6 @@ export type ServerFactory = (
|
|||||||
ctx: MeasureContext,
|
ctx: MeasureContext,
|
||||||
pipelineFactory: PipelineFactory,
|
pipelineFactory: PipelineFactory,
|
||||||
port: number,
|
port: number,
|
||||||
productId: string
|
productId: string,
|
||||||
|
enableCompression: boolean
|
||||||
) => () => Promise<void>
|
) => () => Promise<void>
|
||||||
|
Loading…
Reference in New Issue
Block a user