Assign 2 IPS from cloudflare to two Servers

Hi this may be dumb question. But just eager to know if that possible and I do not know.

I have two VPS and I am uploading images to one of them and then copy images from one VPS to another VPS. I assigned same domain to both VPS ex. Just in case if one VPS fails, I change IP address in cloudflare DNS manually.

So the Question is Two VPS have 2 different IPS, but same domain. Can I assign 2 IPS from cloudflare to both VPS. I have upload images system like this >

Load Balancing is just for Load Balancing. What I want is when I upload an image, it should upload to both VPS servers.

Would load balancing do what you want?

Load Balancing is just for Load Balancing. What I want is when I upload an image, it should upload to both VPS servers.

This is what I want > Screenshot by Lightshot and I am checking if that working or not

Cloudflare will pick one of the servers at random and send the request there. It won’t send to both servers.

Yes it picking up servers at random, I wish it could have send to both of them. Would have been very useful. And I could have used Load Balancing. Now I think load balancing is useless for 95% websites.

How would that work? Which of the two responses should be returned to the client? What if one of the servers are offline?


Sending on both servers is a weird way to achieve that.
What is usually done is that the HTTP traffic is sent to one of the two servers, then the app takes the responsibility to replicate it on two servers.
Let’s take an example of architecture. Let’s say app is written in Laravel and data is stored on MySQL.
You will deploy your Laravel app on both two servers. You will also set up MySQL on both with replication configured.
When traffic comes, it is randomly sent to one of the two Laravel app. Then, when it writes to the database, MySQL will replicate it to the other server instantly and automatically. So no matter which Laravel app will serve later, both have the same data.
When a server goes down, your traffic will be served by only a single server. When it returns available, it has to resync data (automatically).
If you wish not to store image on DB (which is reasonable), a S3-like self-hosted service would be a good choice (MinIO for example, which as I read in the docs can handle the replication process itself). Anyways, replication should be handled at the server level, not at Cloudflare level.

1 Like

Could you achieve this by using load balancing combined with health checks.

i.e. set a high priority on the primary server within the load balancer

When the health check on that one reports unhealthy it would then fail over to the remaining healthy (albeit low priority) server within the load balancer.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.