Reputation: 41
My app is built using ExpressJS, AngularJS and socket.io on heroku's server.
Initially, my client kept getting disconnected with heroku's H12 error code. I believed that my processes are running for too long, but I followed it's advice and reduced socket.io's ping interval to 10 seconds and ping timeout to 25 seconds. My disconnections occur less often after making this change.
Even though the server is only supporting as little as 4-5 clients, disconnections still happen. My app is a simple poker card game that I believe do not require intense computation. At the same time, disconnection is highly undesirable because it is a real-time game. I've also handled most static assets using CDN with AWS cloudfront. Hence, Im wondering whether I should upgrade the CPU of my heroku Dyno or whether it is also necessary to increase the number of Dynos.
Is there any more configurations tweaks that I have to make on my socket.io such as pingintervals and pingtimeouts. Or should I upscale/outscale my Dynos on Heroku? Sorry for my little understanding on server optimisation. Thank you so much in advance for your help!
Below are the LOGs for normal pings intervals, in which there’s no event going on. In this case, there shouldn’t any deep processing going on at all, but as shown in the logs, the GET method took approximately 12s (Heroku will break the connection when it's 30 seconds).
2015-02-05T09:08:59.637350+00:00 heroku[router]: at=info method=POST path="/socket.io/?EIO=3&transport=polling&t=1423127340014-73&sid=MOLTkQP1knsflhZ3AAAB" host=daidi.herokuapp.com request_id=8faf8459-dfb3-4c3b-a7e2-6528c0ab9850 fwd="42.60.78.220" dyno=web.1 connect=2ms service=3ms status=200 bytes=255
2015-02-05T09:09:12.074210+00:00 heroku[router]: at=info method=GET path="/socket.io/?EIO=3&transport=polling&t=1423127340438-25&sid=_5fURAV8_Gn5736HAAAC" host=daidi.herokuapp.com request_id=b54dedb6-1733-414a-8fd3-b8d8fd1f4516 fwd="42.60.78.220" dyno=web.1 connect=1ms service=12008ms status=200 bytes=207
Upvotes: 4
Views: 1901
Reputation: 13799
A single dyno shouldn't have any trouble supporting 4-5 clients (several hundred should be fine). That's assuming that your server isn't doing anything else that's cpu intensive, of course. Keep in mind that if you're running blocking operations on the server, you'll be more likely to disconnect users.
I'd recommend installing a few free addons (strongloop, nodetime, new relic, whichever you like) to get some insight into your cpu / memory / network levels. It also wouldn't be a bad idea to install the event-loop-lag module and periodically output its value to see if anything is holding up your event loop.
Finally, also know that it's very normal to see various errors when using socket.io. It uses a variety of fallbacks, long-polling, etc that can make the router (which is expecting more traditional non-stateful, non-realtime requests) think that something is going wrong. Unless you're seeing issues client-side, I don't know that I'd even worry about it. Of course, if you're seeing client-side issues then disregard all of that... just don't be afraid of H12s for the sake of it.
Upvotes: 1