简体   繁体   中英

Node.js and redis on same server?

We're using cloud hosting (Linode) to host a node.js based (and socket.io) chat app, with redis as the main DB. We haven't launched yet, but we're looking at hosting redis and node.js on the same machine (8 gb instance, redis limited to 5 GB for instance). All communication will be held in redis (ie straight from client to redis, no variables for dialog in node.js). To avoid network travel times amonsgt other bottle necks, we are looking at hosting redis and node.js on the same server. I can't find anything in documentation that would state this is a bad idea, but our sysops guy isn't convinced. Are there any drawbacks to going down this route?

Refer to a very similar answer I posted on a similar matter on SO: Redis deployment configuration - master slave replication where the OP was having a similar issue but his concern was more related to performance.

My main issue with your solution (a simply side note on the other answer) is the simple fact that your node.js application by design has to be cloud facing, eg, the internet whereas your Redis or other Databases shouldn't.

It doesn't mean you'll have a security issue by all means, but in my opinion it's a best practice to only expose the hosts you really need to, eg, the ones usually serving content directly to the user.

By not deploying Redis to an internet facing host you enforce a lot of security constrains simply by the topology design of your network.

Is it ok to host those services in the same box:

Yes, do run the benchmarks from time to time to check if you need to scale horizontally or just bump up the flooded hosts.

Check: Redis deployment configuration - master slave replication

Will I have security problems by having Redis or another service facing the internet?

If you know what you are doing - no, you won't have security issues. I still wouldn't do it though.

I can't comment because I don't have a high enough rep yet, but there is very little speed increase in cutting out the "network bottleneck" redis is so fast that the latency is negligible. The issue with that approach is that if your box crashes then all of your data held in redis is gone unless you are replicating to a slave. If it goes down any other process not on that machince won't beable to access until it restarts. This may be fine for a staging env but I'd guard against it in production.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM