Editor's note: This article from Liouville Contribution (micro-blog @ Liouville Life Road), engaged in the cloud computing industry for many years, from personal experience, and with some Google, Jingdong and other companies cloud computing architects to share the experience of the summary, for you to analyze what is a "shared database."
What is a shared database
Talking about "shared database", the most confusing thing is "sharing" three words. "Sharing" lets us think of the antonym "exclusivity". Yes, the shared database is a kind of database appellation which is based on the ownership of user resources. It is accompanied by the cloud after the coming out of a database innovation, to save resources for the purpose, and generally, their own servers or installed on the computer is not shared data called "exclusive database." Many people do not understand the characteristics of the shared database, then I will briefly introduce.
Comparison of characteristics between shared database and exclusive database
Before you introduce a shared database, analyze what is called the "exclusive database." Exclusive database, as the name implies, exclusive is their own database, before the cloud came out, we have little exclusive database concept, because there is no comparison, that all the database should be called the exclusive database.
"Exclusive database" For example, we have a piece of land (this one has an address and a number, like a database and a port), to build a house on this piece of land. When the warehouse (similar to the database we created), we use the room to store things in the house (similar to the way we can create a Table).
and "shared database" is to save resources, reduce the cost of developers born, many people together to use the building, but this building is not a specific person is the employer's assets. In the cloud-platform world, employers are the providers of cloud databases, and the people who use them are called "tenants." We use a database together, you have permission to create a table, modify the table's permissions, but do not create a database, modify the database permissions, because this building is everyone, not you alone, and you, just one tenant.
Of course, some of your rooms will give you a label, take a name, is So-and-so (the name is the name you use the database later), and your rooms are completely isolated from others, there is no privacy exposure of the problem.
Tenants of shared databases are cheaper to rent because they are charged on demand or even free. "On-demand" is a common feature of the cloud platform, because your room is for storing things, like your database tables are used to save data, in the past you use the exclusive database, you bought a cloud database, is a one-time investment, like you spend a lifetime of savings to buy a house, But do you really need the room to save your stuff?
If you have food, you may not know how many things you have. The birth of a shared database solves this problem, in general, how many things you have, how much you rent the room, the landlord charge you how much. This is called pay on demand. There are many cloud platforms with such services, such as Baidu's Bae, Sina's SAE, Beijing East Cloud and so on. The current database is based on space charges, is not only according to space billing, also according to the flowmeter fee.
At present, different companies in the treatment of shared database technology implementation, the company adopted a different technology and architecture, so can not be one by one of its acceptance, I only briefly summed up the common characteristics of the shared database:
(Note: This is a map of my hand-painted architecture, does not represent the database real schema, only to illustrate the problem and draw)
1 tenant isolation. Multiple tenants sharing the same database instance necessarily requires an effective isolation scheme to prevent a user's slow query request or malicious request from affecting other user access. The isolation implemented here is to intercept all users ' access through the jproxy layer, and according to the index information of the data table accessed by the user, to pre-contract the resource required by the user to execute the request, and to intercept the malicious request and affect other user's request. At the same time in order to accurately control the use of each user's resources, the entire system for users to use the number of connections, memory footprint, disk space usage, bandwidth flow, etc. have done an effective record and monitoring and control according to the user's quota.
2 High consistency protection of cluster routing information. The whole cluster adopts the classic weakly centralized cluster structure, and has enough controllability at the same time to meet the high performance of the cluster, Jmanager manages the whole cluster routing information, and avoids the single point of failure through multiple Slave, when the routing change, Jmanager first synchronizes the routing change information to own Slave, and then all jproxy are synchronized, avoiding the jmanager of routing changes when they are dropped.
3 High Availability protection. Overall cluster all nodes have no single point, the user's database will be zookeeper from the high availability, if the owner of the library hang up, will automatically switch to from the library, and rebind floating IP to from the library, will not affect the user's services. (floating IP know what meaning, want to be an architect friend can search, here do not make a tiring statement)
4 User Database Seamless upgrade expansion. When the user's database data grows beyond the specified quota, the user can choose to upgrade the database, and the system automatically migrates the user database to a more idle instance based on the resource pool usage, and does not affect the user's service during the migration. Through the timing of automatic snapshot of the user database, combined with database Binlog synchronization tools to help users achieve incremental backup, migration is also dependent on these tools to complete the work.
5-type database based on security considerations, through the jproxy to have a potential security risk of the database operation syntax is limited, not to use Create database, just mentioned this House in addition to your use, others are also used, you only these few or dozens of rooms just, You can only fool around in these few or dozens of rooms, you can't go to someone else's room!
After the advent of cloud computing, for enterprises, entrepreneurial teams, individuals brought convenience, the building of the computer room, buy or rent servers to build the environment, middleware, deployment of applications, the domain name and waste a lot of manpower and resources of the era, I believe in the near future may gradually drift away; Convenient and fast Internet services make cloud Platform the future of software services market, and the shared database will gradually reflect its value, to meet the new tomorrow, the relevant talent needs will be followed. I wish China's cloud computing has a vast space for development, more and more people for its services!
(Responsible editor: Mengyishan)