Hacker News new | comments | show | ask | jobs | submit login
Heroku WebSocket performance (veldstra.org)
66 points by hassy 1487 days ago | hide | past | web | favorite | 24 comments



Wow.. 160 connections per second sounds really slow.. is a dyno such a small unit? Never worked with Heruko..


These are WebSockets, not typical HTTP requests. Connections/sec is less important because they will be long-running. The client is not continually reconnecting as they do with an HTTP request.

What matters most is total connection count, which appears to be very high. At 6,000 open connections on a free dyno, that is better than Pusher's $199/mo plan: http://pusher.com/pricing

I think what needs to be done after this is checking how much data can be sent per second. Both in terms of raw bandwidth and messages/sec.


If you're looking for Pusher functionality to run on Heroku, check out http://firehose.io/. Its open-source, so no vendor lock-in and we pump millions of messages through it in production at Poll Everywhere.

I haven't deployed it to Heroku yet, but if somebody does please let me know how it goes!


test


> I think what needs to be done after this is checking how much data can be sent per second. Both in terms of raw bandwidth and messages/sec.

These are on the list :)


Does pusher also work by holding open connections?

If so, it seems that neither option is very respectful of mobile users' battery life...


Obviously take this with a grain of salt since I didn't publish anything, but When I did some analysis on battery life impact of HTTP polling vs websockets two years ago, the difference was completely negligible compared to keeping the screen on (which I had to do for the analysis) on the iPhone 4. This makes sense in retrospect, but it appears as if websockets don't have a huge impact.


Correct me if I'm wrong, but isn't the point of web sockets a persistent connection to the server, to facilitate sending updates? You assume the battery life hit in using them.

It'd be interesting to see the trade-offs between web sockets and persistent polling.


I did extensive research on this about 2 years ago for Android. Holding long standing connections is much more efficient than using multiple HTTP requests, polling included.

The reason being mainly the session negotiation and teardown required for making multiple requests, and the fact that the antenna required a higher energy state for creating a new connection compared to keeping an existing connection open.


Is it the same result using cellular vs. using wifi?


Somewhat, but multiplicative. Wifi requires a good deal more power to begin with, and the high power state of wifi is one of the biggest drains on battery life (after the screen).


What is it about an open connection that would drain the battery? It's not like it has to consume a thread in a busy wait.


That's 160 new long-lived connections per second, which will presumably stay open for the entire duration the user is on a webpage.

If you're getting 160 users connecting per second the 6000 concurrent connection limit will be hit in less than a minute, assuming most users stay on the page for longer than a minute.


Does anyone know if the free Dyno is always running or it's started once there's a request and killed after a timeout?

I couldn't find this info in the pricing page.


Correct. If you're running more than one dyno in an app, however, there are no 'timeouts'.

If you're trying to maximize your free dyno usage, however, you might want to use the 'heroku scheduler' addon, and have it ping your app once every 10 minutes to keep it 'awake'.


Yeah, it's killed after a timeout and restarted when a new request comes in. Which is why when you revisit an old Heroku app it takes a long time to load.


You can keep a single free Dyno "awake" by hitting it with a request at least once per hour. If you use New Relic the built in availability monitoring will do the trick and otherwise Scheduler should work. For more info:

https://devcenter.heroku.com/articles/dynos#dyno-idling


Now you can also check if your app is sleeping on the dashboard :)

https://blog.heroku.com/archives/2013/6/20/app_sleeping_on_h...

Also, I used pingdom.com once to make sure that my "very low in traffic" app never sleeps, but any solution that performs a request in this interval would be valid


How does 160 connection per dyno compare to comparably priced servers elsewhere?


That's per dyno, per second. 6,000 per dyno total, which seems very reasonable. As timdorr mentioned, Pusher's largest (publicly available?) plan only allows for 5,000 connections.


We run http://firehose.io/ on smaller SoftLayer metal servers and get around 10k connections per box. These servers cost $250 per month, so we get about 20k connections for $500 per month. By my back of napkin numbers Heroku is about 10x the cost of real metal servers.


I ran a quick test, an entry-level box from Digital Ocean can sustain 350+ connections/sec and maxes out at around 7,200 open connections.

Having root access to the machine would allow you to optimise some things and probably raise those numbers, but then you don't get the convenience of using Heroku.


You might want to check out https://github.com/observing/thor, it's basically wrk/ab for sockets.


It would be really interesting to see the same test done with 2 and then maybe 3 dynos running. I'm wondering how well would that scale with more dynos running. Is it possible to buy dynos for shorter time than a month?




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: