Make scalable NodeJS app in Wappler without special knowledge

Recently one of my websites increased the number of simultaneous visitors. And because I didn’t do any specific settings, I faced the problems with site perfomance.

Good folks here explained to me that NodeJS is a single-threaded app by default. Which means that no matter how many CPUs I added to my VPS, it still only uses one.

There are several methods to improve that. I suppose it is not a problem for professional web-developers. Maybe it is even very simple.
But for nocode-developer like me, a better option is to find a developer or devops to solve it. It’s not a big deal of course.

But I think it would be fantastic if Wappler could handle this issue right from the box.

Definitely more safe than manually changing project settings. :slightly_smiling_face:

I wonder what kind of load the Wappler project can hold without additional manual settings? @George, do you have any figures on this? All my projects were designed to work with a small number of users, as they were CRM systems of small companies. Therefore, I have not yet encountered problems with high online. However, I think this is a very important topic. Therefore, it is very interesting how much the Wappler project is able to withstand with default settings. @nickneustroev in your project, the performance problems started at what online?

There is no such thing as "what kind of load can a Wappler project hold", this cannot be measured. It is so really specific to any project and the way you build it. It's like asking what's the maximum speed of any car - it depends on so many different things. A Lada 2105 can go up to 110-120 km/h but a nice sports car can go up to 280km/h or more :slight_smile:
Hope you understand what i mean.

I understand what you mean, @Teodor. I am well aware that different projects created on Wappler will work differently. And it is obvious that “Hello World” will cope with the load much easier than a complex messenger that requests hundreds of parameters from the server if they are run on the same hardware. However, it would be very nice to have some kind of research in which a project created on a Wappler with the specified parameters is launched on a specific VPS and checked for load. So that developers on Wappler can use this testing as a guideline when developing their projects and designing the architecture.

If you are running NodeJS with docker on your live server, and have also installed Traffic for SSL and domain management, you can simply run multiple instances by entering more replicas:

image

This will create as many NodeJS instances of your site as you enter replicas and those will run simultaneous and be load balanced by Traefik so users are spread (round robin)

3 Likes

How does it work with socket connections of users in different instances? Can they send socket events to users in other instances? If not, how to make the project scalable with socket events?

This is interesting; had no idea that Traefik could also provide load balancing functionality. Can the number of Replicas be added anytime? Currently this has been left blank in my NodeJS projects.

Yes, it can be added anytime - Traefik reconfigures itself internally. Replicas are a Docker functionality

Thank you! Turns out, it was already there all the time. :slight_smile:

Just tried it for the test target. Indeed, it has created multiple containers with an app, I see them in Portainer.
I turned on the Redis so it seems like all websockets work fine too.
So at first sight everything is ok.

But of course I need to check how these settings influence performance of the website. I will come back with results.

I believe, Patrick has answered here:

1 Like

Thanks @Apple; I will try it out in my latest project.

This is actually quite a common scenario that any container software handles. I.e. Kubernetes, Docker(Swarm).

It’s called “horizontal scaling” if you want to look into it. As opposed to vertical scaling which means to add more resources to your infra(cpu,ram,etc).

Yes that is exactly the perfect combination, NodeJS multiple instances with Traefik for SSL and load balancing, and Redis for Sessions store to share between the multiple NodeJS instances!

Curious about the performance now :slight_smile: - definitely should fly now! Of course the more multi cpu cores you have on the server - the better as well.

First, it was a basic cheap VPS with 1 cpu 1 ram.
It failed when 200 concurrent visitors been reached.

Then I add a juice to VPS up to 6 cpu 6 ram.
It became better, but a little bit. With 500 users troubles came back.

Then I tried to configure the pessenger in Plesk to make several copies of the app.
It worked perfectly with 400 visitors. I wasn't able to check with more users yet, but synthetic tests show some hope.
But obviously the sockets didn't work correctly.

So now I am using docker setup to solve all this problems out of the box.

Next big event with hundreds of users would be in two weeks.
But I'm gonna run some synthetic tests with Docker setup soon.

You can try:

1 Like

@George Any resources on how to get Redis working on Caprover type Docker setup?
I ask you and not search directly is because you could give me a direct resource based on Wappler/Caprover setup and what could work best.

Caprover already has a cluster setup, so the horizontal scaling part is already covered. But ability to add Rezdy would be a great addition.

Caprover UI includes a one-click redis install.

Yes, but how would it integrate with a Wappler app?

What do you mean with integrate? Connect to it? IP and port. Straightforward.

1 Like

Yeah, how does he sets the IP and stuff on the Wappler config he’s asking

1 Like