Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TSK-1500: Enable compression by default #3177

Merged
merged 1 commit into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dev/prod/src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
2 changes: 1 addition & 1 deletion models/all/src/version.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "major": 0, "minor": 6, "patch": 93 }
{ "major": 0, "minor": 6, "patch": 95 }
5 changes: 4 additions & 1 deletion pods/server/src/__start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -92,7 +94,8 @@ const shutdown = start(url, {
serverFactory,
indexParallel: 2,
indexProcessing: 500,
productId: ''
productId: '',
enableCompression
})

const close = (): void => {
Expand Down
5 changes: 4 additions & 1 deletion pods/server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ export function start (

indexProcessing: number // 1000
indexParallel: number // 2

enableCompression?: boolean
}
): () => Promise<void> {
addLocation(serverAttachmentId, () => import('@hcengineering/server-attachment-resources'))
Expand Down Expand Up @@ -336,6 +338,7 @@ export function start (
sessionFactory,
port: opt.port,
productId: opt.productId,
serverFactory: opt.serverFactory
serverFactory: opt.serverFactory,
enableCompression: opt.enableCompression
})
}
3 changes: 2 additions & 1 deletion server/front/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ export function start (

// fallback to standard filter function
return compression.filter(req, res)
}
},
level: 6
})
)
app.use(cors())
Expand Down
4 changes: 3 additions & 1 deletion server/ws/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -517,6 +518,7 @@ export function start (
ctx,
opt.pipelineFactory,
opt.port,
opt.productId
opt.productId,
opt.enableCompression ?? true
)
}
31 changes: 17 additions & 14 deletions server/ws/src/server_http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion server/ws/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,5 +164,6 @@ export type ServerFactory = (
ctx: MeasureContext,
pipelineFactory: PipelineFactory,
port: number,
productId: string
productId: string,
enableCompression: boolean
) => () => Promise<void>