is a project in the 99 years began in the campus, a few people do as a hobby such an application, in order to achieve the following functions:
LiveJournal uses a lot of open source software, even if it itself is an open source software.
After on-line, LiveJournal very rapid growth:
LiveJournal to 100 servers from a server development, which has experienced numerous pain, but also worked out a solution to these problems, through LiveJournal learning, allows us to avoid LJ had mistakes in the past, and good design of the system from the outset, in order to avoid the pain of late.
Let‘s step-by-step look at the pace of development of LJ.
Others a donor server, LJ initially run at the top, just like Google began when broken server, worthy of our respect. At this stage, the LJ at an alarming rate familiar with the Unix operating management, server performance issues, Fortunately, you can change some minor repairs to muddle through. At this stage LJ upgrade CGI to FastCGI.
Final problem, the site is getting slower and slower, has been unable
to pass too excellent to solve the point, you need more servers, then LJ began
offering paid services may want the money to buy a new server to resolve then
predicament.
There is no doubt that when LJ there is a
huge single point, everything in server tin box filled.
Earned money paid service LJ bought two servers: one called Kenny Dell 6U machine is used to provide Web services, called Cartman Dell 6U server used to provide database services.
LJ have a larger disk, more computing resources. But
at the same time, the network structure is very simple, each machine two network
cards, Cartman Kenny intranet MySQL database
services.
Temporary solution to the problem of the
load, a new problem has emerged:
Bought two, Kyle and Stan, this is 1U, are used to provide Web services. LJ, a total of 3 Web server and a database server. At this time both horizontal load 3 Web server.
LJ Kenny gateway for external mod_backhand to both horizontal load.
Then the problem has emerged:
Bought a database server. On two database servers using the database synchronization (MySQL support Master-Slave mode), the write operation all the master database (by Binlog, the write operation on the master server can quickly sync from the server), the read operation in two the database at the same time (it can be considered both horizontal load a).
Synchronize to the attention of a few things:
Money, of course, to buy more servers. Fast deployment did not take long, they began to slow. The more Web servers, database servers, there are IO and CPU contention. So the BIG-IP load balancing solution.
Server is basically enough, but the performance is still a problem, the reason for the structure.
The structure of the database is the biggest problem. Slave mode due to the increase in the database are added to the application, so the only advantage is that the read operation is distributed to multiple machines, but such consequences is a write operation is distributed, each machine must be running the server more , the greater the waste, with the increase of the write operation, the fewer resources used to service the read operation.
Distribution from one to two
The final results
Now we find that we do not need these data in so many servers keep a copy. Have done a RAID server, database backup, so the backup is completely a waste of resources, a redundant extreme excessive. Why not the distribution of data storage?
The problem is found, start thinking about how to solve. To do now is the distribution of different user data to a different server for storage, in order to achieve the distributed storage of data, each machine only for fixed relative to the user, in order to achieve parallel architecture and good scalability .
In order to achieve user group, we need to be allocated for each user a set of tags used to mark user‘s data is stored in the database server in which group. Each group database consists of one master and several slave, and the slave in 2-3, in order to achieve the most rational allocation of system resources, both to ensure the distribution of the data read operation, but also avoid the excessive redundancy of data and synchronous operation of system resources excessive consumption.
User packet control is provided by a (group of) central server. All user packet information is stored in this machine, all users need to query the user group number of this machine, and then to get the data in the database group.
This user structure and the LJ architecture has very similar.
In the specific implementation, a couple of caveats:
Question:
Single point for Master-Slave mode, LJ adopted a Master-Master mode to resolve. Master-Master is actually artificial, not provided directly by MySQL, which is actually two machines at the same time is the Master, also is the slave, synchronized with each other.
Master-Master achieve need to pay attention to:
Solution:
Master-Master mode there is a use of this method with the former compared to still maintain the synchronization of the two machines, but only one machine (read and write), rotation every night, or appear problem when switching.
Now an ad spots MyISAM vs InnoDB.
Using InnoDB:
Use MyISAM:
Last year, I wrote , it is a caching tool developed by the team of LJ, key-value way to store data to distributed memory. Data LJ buffer:
How to create a cache strategy?
I want to cache all things? It is not possible, we only need to cache or may result in system bottleneck submission system efficiency. MySQL log analysis, we can find the cached object.
The disadvantage of the cache?
At the packet level using the BIG-IP, BIG-IP does not know our internal processing mechanism, can not determine which server processing these requests. The reverse proxy does not play a role, not been fast enough, that is, up to less than the effect we want.
So, LJ the development . Features:
LJ use open source as the distributed file storage system. MogileFS very simple to use, its main design idea is:
So far so many more documents can be found in the . students take this document to participate in two MySQL Con, twice OS Con, as well as numerous other meetings, selfless to share their experience, that we can learn. In web2.0 era rapid development to get more and more attention, but good design is still the basis of each application, web2.0 in the way of growth Top500 website, not because of the architecture hindered the development of the site.
Development of large-scale site performance optimization method from LiveJournal background
原文:http://www.cnblogs.com/bruceyo/p/3697466.html