How to implement auto-transition in the fall of the VPS server?

The question is simple but did not meet the recipes - and what to do if suddenly dropped (or blocked) VPS
Well, maybe the same is going to happen, forgot to pay, or evil zoster turn off your VPS - what to do, and you're warm belly of the sea?
There are in nature any thing like this or a similar case.

Thank you
April 4th 20 at 13:24
4 answers
April 4th 20 at 13:26
Solution
To have a backup server with a copy of the server (files, replica DB).

Pre-set DNS second IP (backup server).

In the fall of the server to receive a notification to activate a backup server (running nginx and everything else that is required), verify proper server operation and to continue to warm the belly.
April 4th 20 at 13:28
Solution
a month and a half working on a solution on this issue, and for more than a month one is already made the decision.
If the short is
- two KVM VPS in different data centers (400 - 700p per share)
- nginx:80 -> apache:8080
- Mysql replication master-master
- file replication via clsync
replication configs (nginx, apache, php, ssl, postfix) using clsync
- work with configs only on 1 server. Update SSL only on 1 server
- replication sessions using php memcachedrep
- DNS round-robin, 2 And write
- all traffic nginx transmit only on 1 server, the second marked as backup
- added monitoring via zabbix on everything to see what works
- you can still use a DNS hosting service with API to Zabbix is not available to remove the ip from the DNS issue.

Example: one of the servers is unavailable/disabled.
If you check how DNS works in round robin, you will notice this algorithm:
1) browser connects to 1 ip issued
2) tries to connect for 2 - 2.5 seconds
3) if not, then connects to the following ip
4) because 1 server is down, nginx switches to my internal apache and works with him
PROFIT!

If interested, please, tell me https://t.me/konstantinti
If you want to do it all entirely by himself, please do.
Interesting solution.
Question - what network are you going to sync the database? (internal network or through the white SP), who is the hosting provider, Hetzner? :) - lila.Ankunding commented on April 4th 20 at 13:31
@lila.Ankunding, because data centers are different in different companies, we have 2 white ip, so everything goes through the Internet. It is logical that both data centers were in 1 city. In this case, in Moscow.
forgot to add, replication through php sessions memcachedrep - Christelle.Mosciski commented on April 4th 20 at 13:34
Uh... and you can address where in Moscow VPS for 400-700 rubles? - lila.Ankunding commented on April 4th 20 at 13:37
@lila.Ankunding, https://ihc.ru/ https://hoster.ru
Yes a lot of them, you feel like Google does not use it - Christelle.Mosciski commented on April 4th 20 at 13:40
@Christelle.Mosciski, believe it or not, Google almost never use Yandex as a closer and relevant :)
odd I do not trust our hosting providers have the sad experience and jino firstvds - needlove specific, loaded users on the server while he is barely moving (and at first, Yes, runs fast - but not for long). Although it is possible that the situation today has already improved.
PS still our almost 2 times more expensive than the same Hetzner. - lila.Ankunding commented on April 4th 20 at 13:43
@lila.Ankundingfor this scheme I have concluded that VPS is better to take only the hardware virtualization, such as KVM.
On OpenVZ there, Yes, resources can share and there are limitations on hosting. For ihc on OpenVZ rates, no iptables conntrack module, like a trifle, but can spoil the setting of the UPU.
From jino Yes, it has its own nuances, they intercept port 443, because of which there may be complexity in setting up SSL.
At firstvds bought only cheap rate for 90 rubles, for blog enough, more Nitsche not know.

Can you provide a link to prices where you cheaper found on Hetzner. - Christelle.Mosciski commented on April 4th 20 at 13:46
April 4th 20 at 13:30
Read mail, and to configure monitoring.
well, I suppose I learned - and what next? To tear your ass hair? :) - lila.Ankunding commented on April 4th 20 at 13:33
@lila.Ankundingmay not tear. Hire administrator. - margaret_Tromp99 commented on April 4th 20 at 13:36
@lila.Ankunding, have an emergency server/s that would be paid with the offset to the main - julius43 commented on April 4th 20 at 13:39
@julius43, well, OK, suppose there is such VPS where you sleep - how to flip it traffic machine? Or is it impossible in principle?
Can cost to smoke the issue with load balancers - they are in principle, probably enchanted by it? - lila.Ankunding commented on April 4th 20 at 13:42
April 4th 20 at 13:32
Solutions are available but cost money and labor.
A few examples:
1) Multiple servers from different hosters, loadbalancing using Cloudflare or Incapsula or the like.
Expensive, plus you need to configure replication of data, if the site is not static.
2) AWS/GCP/Azure - multiple servers in different availability zones and / or regions, and the loadbalancer and DNS.
Again - the data replication.

To discuss options more specifically, you need to understand that you have a website.
Ordinary LAMP , the client, about 10 pieces - lila.Ankunding commented on April 4th 20 at 13:35
Options again several. The main question is - does the data in the database and if we want active-active or active-passive architecture. If we are talking about AWS, loadbalancing and\or failover can be arranged using ALB and Route53.
And lasanowski option managed MySQL supports multi-master https://aws.amazon.com/blogs/database/building-hig...

here is one example
https://medium.com/dazn-tech/how-to-implement-the-...

Slightly oftopik - as I wrote in another reply

I would start with an analysis of the causes of the non-working site - to understand whether the use of multiple servers to increase reliability. In many cases it is not. For example - problems at the host. Then we move on to another. For example, the database service crashes. Then you have to configure it correctly, optimize queries, etc.
how to increase the reliability of the application, placing it on multiple servers

Multiple servers can help protect against the "iron" problems on a specific server (which happens very rarely), plus, in certain cases, to solve the problem of scale.
This will cost money - and the servers and implementing solutions. In the event of incorrect implementation of it can impair reliability.
So back to the question - why the site is now unreliable?
- vernon commented on April 4th 20 at 13:38
@vernon, thanks for the detailed answer! Yes, the site is more or less reliable, I'm not sure in the DB which has the property of or fall or blunt - lila.Ankunding commented on April 4th 20 at 13:41
@lila.Ankunding, then I advise you to understand and improve the situation with the base.
To run logs, including the slow query log, set the database to optimize queries. To increase the database instance if necessary. - vernon commented on April 4th 20 at 13:44

Find more questions by tags HostingHigh availability