Skip to content

Conversation

@FZambia
Copy link
Member

@FZambia FZambia commented Nov 29, 2025

This PR improves CPU utilization under load in scenario when WriteManyFn is actively used (message batching scenario).

For bench run with throughput limited by publish rate (to make conditions equal):

go build && WRITE_DELAY=200 MAX_FRAME_MESSAGES=-1 ./bench_server
go run main.go -s ws://localhost:8000/connection/websocket -n 100000 -ns 500 -np 100 -pl 10 -p channel

This effectively reduced CPU usage from 56-60% -> 48-50% on my machine.

Before:
Screenshot 2025-11-29 at 5 32 50 PM
After (no incTransportMessagesSent at all):
Screenshot 2025-11-29 at 5 34 29 PM

@FZambia FZambia changed the title Reduce Prometheus metrics overhead in write many path Reduce Prometheus metrics overhead in batching scenario Nov 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants