-
Notifications
You must be signed in to change notification settings - Fork 335
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
apns push performance #68
Comments
Let me know how you get on, and i will look to close this in a few days. |
Would anyone be able to share what sort of performance they are getting in terms of req/sec/core? I have existing PHP solution that uses legacy socket connection api and is able to send 1000/sec/core notifications. I'm currently getting 10x less with Go on the same hardware. I feel the biggest issue is that the client has to wait for the server response with the new api, where before it would just open a socket and stream the data nonstop while listening to feedback endpoint for errors in parallel.
Thanks. |
@serg472 If you create a worker pool to send the notifications using the existing API, you can send many more notifications. On a small test I used 20 workers with the Buford APNS library to send 400 notifications/sec. You should be able to use a similar pattern with @sideshow's apns2. From discussions with Apple, it should be possible to have 4000 open streams with the new API (therefore 4000 workers), but the number is dynamic. Too many steams and Apple starts giving errors, and I don't yet know a good way to adjust it on the fly. If you pick a fairly safe number, such as 50-100 workers, you should have little trouble besting the legacy PHP solution, plus the new API has the benefit of returning error responses immediately instead of needing the feedback service. As to the mention of cores, it's up to the Go scheduler to distribute your workers (goroutines) across cores, scaling to how ever many cores you have. Thus the more relevant number is the how many workers = goroutines = number of http2 streams. |
Thanks. I increased the amount of goroutines to be well in hundreds and it seemed to help (still 2x slower than socked api currently but it's manageable, don't think individual http calls could ever match one-way socket streaming speed). The sweet spot for me seems to be at around 400 threads (32 cores). |
Thanks for the update. @serg472 I agree, the socket streaming has less overhead so it should be possible to go faster. The socket streaming comes with it's own set of downsides though. As far as 400 threads, it so happens that Apple servers inform the client on how many streams can be used. In the newer JWT API they start with 1 stream and then ramp it up. Currently the HTTP/2 package for Go doesn't expose this information, and I'm not exactly sure how to proceed there. If we had that information, we may be able to ramp up the threads dynamically based on what the Apple servers tell us. Here is the issue I opened for Go: golang/go#17265 |
Hm interesting. I spent a lot of time testing in past few days and performance seems almost random, at some point 400 looks like a clear winner, an hour later 100 performs the best and 400 is 3x slower. If Apple dictates the amount of connections that makes sense now I guess. @nathany Can you please elaborate a bit more about this. So when http2 client is created and apple lets say allows 100 streams at the moment, what will happen when apple changes this number, will the client follow or it will stay at 100 until closed? If so, would it make sense to recreate clients from time to time to reset this counter? |
Apple's server send settings whenever they change how many streams they are allowing. See How to adjust for it, I'm not entirely sure yet. Maybe switching on/off some of the workers? For now I'm just curious if there is a good way for x/net/http2 to expose those SettingMaxConcurrentStreams events. There may also be some difference between the # of streams Apple allows and the optimal numbers you were finding... so perhaps that number isn't as useful as I think. |
about the demo using channel,is it safe to use one sokcet in multi-workers? |
@runner66 Yes the channel is safe for concurrent access. |
Hi @silver0511, I added a page to the wiki around push speed and what you could expect to get in terms of throughput. Interested to hear how you got on with this. I was able to get more like 4,000 p/sec per core. See https://github.com/sideshow/apns2/wiki/APNS-HTTP-2-Push-Speed |
Is the performance different for dev endpoint vs prod ? |
Hi,when i execute this code(res, err := client.Push(notification)), it cost about 1~3 seconds. but i want push more(probably push 1000 per second). how can i improve the performance. Thanks
The text was updated successfully, but these errors were encountered: