I am designing a chat application in NodeJS using express, mongo db, socket io. What points should I keep in focus while designing the architecture for this application. The target audience for this app is going to be more then 50K users concurrently using it.
I have previously in my career designed apps that were used by 2k end users at max. But this is something new for me. I did a lot of research on it and came up with the following points.
1- Start using queuing services like RabbitMQ
2- Increase your server space/ram as the usage increases.
Can someone please point me in the write direction a book on NodeJS architecture patterns and scalability. A guide, a walk through any sort of help is highly appreciated.
Here some tips:
You should take a look at the Cluster module you can also use wrk for HTTP benchmark.
Make sure you use caching.
If you are using Docker you should use the swarm mode.
Use Amazon Elastic https://aws.amazon.com/ec2/
Related
In the company I work for,
we plan to renew and re-code our 12 years old , online sales web application.
Our traffic is a bit high ; over 100.000 sales orders a day
means there will be at least 1 million interactions for a day on the web application.
I'm want to use NodeJS as web the server which will be integrated to our ERP system running on Oracle Exadata database.
My question is :
Performance is Very Very critical for us, I'm not sure NodeJS is scalable enough for this high transaction count.
I've read some blogs on internet which states some very very big companies uses NodeJS already,
but I'm not sure they use it as main & backbone system or only for some smaller applications in corporate usage.
Can you share your experiences , if possible with examples including transaction count ?
Thanks in advance !
Why are you looking at Node.js? What other options are you considering? Why choose one over the other? What expertise does your team have?
Node.js is quite scalable, provided you know what you're doing. How much of your load is mid-tier vs database? If there's a lot going on in the mid-tier, then you need to be able to scale it out horizontally. Here are a few high-level things to consider:
Many people use Docker to containerize their apps and scale them out with Kubernetes (though those aren't Node.js specific).
You'll likely want to learn about PM2 to keep your Node.js processes running.
Use node-oracledb connection pools.
Use bind variables for security and performance.
Look into using DRCP if you are using Kubernetes and each container has it's own connection pool.
Consider looking through this guide to creating a REST API with Node.js and Oracle Database to get an idea of how things work:
https://jsao.io/2018/03/creating-a-rest-api-with-node-js-and-oracle-database/
I have deployed my nodeJS backend on Heroku Hobby dynos. There are 1500+ active users. So the API response time is very slow some times, Please help to figure out which dynos is better for backend deployement.
It always depends on your application. What type of operations and workload are you handling in your API, do you have any synchronous/blocking operation? Is there a lot of I/O involved? More information about what you are trying to achieve would be helpful to give a better recommendation.
One best practice for Node.js is to scale horizontally, this means, having multiple small servers to handle traffic instead of having one big server (vertical scaling). So, a good recommendation is to scale using multiples dynos, try to scale to 2 and measure again to see if it fits your performance needs.
Some recommended readings:
Good practices for high-performance and scalable Node.js applications
Optimizing Node.js Application Concurrency
I am building a Node application that has a front end standard API for a SPA and a backend service that is constantly polling another API, I am going through the Node documentation in regards to clustering, forking and workers and am a bit confused and am unable to come across anything that adequately addresses the question I have.
I would like to have the 2 different API's on 2 different server cores but use the same codebase. I have experimented with 2 node entrance files app.js and app1.js both work just fine on the same server, but this was a very very simple implementation.
Is this wise to do? As stated above I will need to have the same codebase available for both services to perform business logic.
I am having a hard time finding examples or envisioning what this would look like, would I just do the 2 app.js entrance files? What about getting these services on different processor cores? Is this possible? I am assuming I could communicate between them using IPC? But do I use clustering? Forking?
A quick and simple example would be very useful as I am still pretty new and this is very advanced for me at this stage but I just need a small boost in how to get this rolling. Thanks for any help.
What is the killer reason to use remote db hostring services for MongoDB (like compose.io) for nodejs application VS hosting MongoDB on the same network (in the same datacenter, etc), for example when using PAAS providers (like modulus.io) which offer "integrated" MongoDB hosting .
What percentage of speed/perfomance may degrade when using internet remote DBs, how do DB providers you solve this? How to make right decision on this?
The reason you use something like compose.io is that you don't want to deal with that on your own and have experts taking care of it that know what they are doing. In the best case with support so you can take further advantage of those experts. And that's the only reason.
If you use Modulus that has this anyway and you run your application there as well - even better. There is no real reason to run your node application on Modulus and your mongodb on a different cloud hosting service.
In practice that probably doesn't matter as much because they all use AWS anyway ;)
Important: If they DON'T run in the same network make sure your mongoDB is protected properly(!!). If you do run in the same network just make sure the mongoDB is not accessible from the outside at all which is def the better solution!
Hope that helps
I am developing a chat application using the nodejs/socket.io on the server side
Now, it is time to test how scalable it is
so, i think i can simulate a large number of soket.io clients effectively using nodejs also , but running the client code this time
the question is, How can i run the socket.io client library on nodejs? is this possible?
if so, can anyone please provide a simple example
my code is running fine on the browser, with the usual development load, the issue is not about the code is running or not, actually i am not planning to run the same client code, just openning a large number of connections , and sending thousands of messages to have a preliminary figure about scalability and resource consumption
also, any suggestion on testing socket.io server scalability will be appreciated
thanks a lot
What you're looking for isn't going to really be helpful. Even if you could simulate client-side socket.io in a node process, it wouldn't have the same dynamic properties as actual access from browsers. You'd be able to determine things like the maximum number of connections you could handle without running out of resources, but your general performance metrics would be pretty artificial and not generalizable.