5 ms·
Node has some pretty unique benefits, I save a good $1000/month from switching from .NET on dedicateds to NodeJS on a PaaS (Heroku), and that was after 2 - 3 ye
by benologist 14y ago
Node has some pretty unique benefits, I save a good $1000/month from switching from .NET on dedicateds to NodeJS on a PaaS (Heroku), and that was after 2 - 3 years of writing and rewriting and optimizing the .NET stuff.
Biggest improvements came from persistant connections to redis/mongodb and polling for updated information independently of requests so there was no cached-or-fetch shenanigans at all in some areas.
- statictype 14y agoWhat were the benefits you saw in switching from .NET to Node? Was it in basic code structure/complexity or performance? I'd actually be very surprised if NodeJS running on Heroku (which is built on EC2) performs better than compiled .NET code running on dedicated Windows hardware.
- benologist 14y agoThe major benefits were persistant connections and background fetching of data - a lot of my requests serve data directly from local memory instead of hitting local or shared caches and databases. The equivalent in .NET I guess would be BackgroundWorkers that are independently prefetching the data required most of the time but I could never get them to Just Work. Specifically for my use case 99+ percent of requests receive some data, do some light manipulations and then push the data to redis about 8,000 to 12,000 times a second. With .NET I could only push to locally running software instances because anything remote couldn't keep up with the connection volume (without throwing even more hardware at the problem).
- statictype 14y agoInteresting. Thanks for the answer. I'm a little surprised that .NET can't juggle network connections very well but in retrospect, I probably shouldn't be.
- benologist 14y agoI think it's just whatever .NET's doing to pool them that has some tiny bit of overhead that doesn't matter most of the time.
- gizzlon 14y agoInteresting.. how often do you pull from the db's? Do you think about it as a write-through cache?
- benologist 14y agoEvery 30 or 60 seconds + the data's timestamped so it's usually a pretty minimal refresh. It's really just like using any memcached or the built in .net caching rather than a write through one, new data reaches each dyno either via the periodic refresh or when it tries to create that record and finds it already exists. Writes are done immediately and the caches don't get updated because there's 8 - 16 dynos and why bother updating the single dyno that created it. I did originally use redis pub/sub to push out updates to everything but I ended up removing it because it was unnecessary. Here's some example code, it pre-fetches all the leaderboards (not scores) every 30 seconds: http://pastebin.com/asq6eExu http://pastebin.com/asq6eExu Higher up in the same script is the api for the leaderboard data with stuff like: http://pastebin.com/gsfvsZsv http://pastebin.com/gsfvsZsv
- commentzorro 14y ago>> " I save a good $1000/month from switching from .NET on dedicateds to NodeJS on a PaaS (Heroku)" I'm really puzzled by this. A single dedicated large .NET box (16GB RAM and 6 Core Processor, 1TB raid, etc.) runs $150 a month. When I was looking at PaaS, Heroku came in more than five times that much for similar capability. $1,000 a month gets me SIX of these dedicated boxes that can be tied together as needed. Why was your setup so much more for dedicated that you could _save_ that much, much less why you would be spending that much in the first place?