SkygearIO / skygear-server

Skygear - an open source serverless platform for modern secure app development
https://skygear.io
Apache License 2.0
408 stars 84 forks source link

Pubsub performance #575

Open carmenlau opened 6 years ago

carmenlau commented 6 years ago

When we are working on the chat plugin, we found that server need certain time to consume few hundreds pubsub events. Need to perform some benchmarking. Please list the result here and see any improvements should be made.

howawong commented 6 years ago

Not much finding. Did checking with pprof and the server code looks fine. In our previous test case, the total number of subscriptions is low. (We just created many participants, but did not really log into and subscribe). So the busiest part is the reader code. https://github.com/SkygearIO/skygear-server/blob/61ac26661b94af4220236c03dcbf90553d6267d3/pkg/server/pubsub/ws.go#L101 And most of the time is spent on messageType, p, err := c.ws.ReadMessage()

I think one of the easiest way to handle the problem is to reduce the number of calls in order to send the same message over hundreds channel which pubsub payload should also support channels parameter.