C
C
cyberorg2013-06-03 20:55:14
PHP
cyberorg, 2013-06-03 20:55:14

Data replication for two web servers and website scaling questions?

Initial data:
There is a website that runs on a bunch of Linux + Nginx + PHP (+ Yii framework) + MySQL.
Disclaimer: some of the moments may seem very noob. But I will be very happy with constructive criticism of the questions themselves and guidance on the true path, because I have never done anything like this before.
What we need:
Duplicate each of the components. Ideally, taking into account subsequent scaling to new servers.
As a result, I designed it like this:
2 frontend nginx'a, which accept all requests and return static. Balancing queries in frontends using DNS Round Robin.
2 backend servers with PHP_FPM and memcache. Balancing calls to databases is in Yii itself (our programmers told me so).
2 MySQL database servers.
All servers will be running FreeBSD.
Questions:
1) How to organize synchronization of statics between two frontends?
2) How to balance requests to backends?
3) Does it make sense to duplicate memcache or is it better to let two independent memcache work?
4) Is it optimal to use PHP-APC together with memcache?
5) Does sharding make sense if master-master MySQL database replication is used?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
betal, 2013-06-03
@kyberorg

Everything is almost like yours, I have a lot of experience in this all.
>2 frontend nginx, which accept all requests and return static. Balancing queries in frontends using DNS Round Robin.
Do not do DNS Round Robin, if something falls, it takes a long time to restore, it’s easier for me, if the client’s ip is even then files1.site.ru, if odd then files2.sites.ru. If the static server has fallen, remove the idle domain from the output. and transfer the load to the worker.
1) My static is copied as needed.
2) By means of nginx :)
3) For me, if one memcache is not enough, then they make a division based on keys, so part of the information is on one server, part on another, but not duplication.
4) You compare different things, if the question is about caching some data, I would choose memcache.
5) The question is what to choose, fault tolerance or speed.
PS.
> Balancing calls to the bases is in Yii itself (our programmers told me so).
Is it? I once wrote this part myself. And in order to avoid an error like Race condition, it is necessary that not the framework was written correctly, but the program itself. Master - Master replication, even in theory is quite complicated. I wouldn't encounter such structures that are difficult to maintain unless absolutely necessary (at least until mysql officially supports these structures)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question