Two introductory articles have been written about MyCat:
- MySQL can only do small projects? A few words of justice for Songko!
- Northern destiny has Data, its name is Kun, kun big, a MySQL can not put!
Today is the last foreshadowing, then we can meet the big Boss!
I was supposed to talk about MyCat today, but I found one more concept worth talking about is Java middleware!
Because MyCat is a distributed database middleware, to understand MyCat, you need to know what middleware is!
Songo, who spoke on middleware at a workshop last year, wanted to share his notes directly, but couldn’t find them, so he typed again.
Introduction to Middleware
When it comes to middleware, many people first think of message-oriented middleware, but what about other than message-oriented middleware? In fact, we are exposed to too much middleware in our daily development. Let’s take a look at wikipedia’s introduction:
Middleware, also known as the Middleware layer, is software that provides the connection between system software and application software to facilitate communication between software components. It is widely used in modern information technology application frameworks such as Web services and service-oriented architecture. For example, database, Tomcat of Apache, WebSphere of IBM, WebLogic application server of BEA, Tong series middleware of Dongfang Tong and Kingdee company all belong to middleware.
You might be surprised at how much middleware we’ve been using before we even knew it! Even Tomcat is a middleware!
Middleware, as the name suggests, is the thing that connects two pieces of software, the glue, the glue between the pieces of software. It sits between the operating system and our applications, allowing developers to easily handle communication, input, and output, allowing developers to focus on developing their own business logic.
It sounds like Tomcat is still a bit like middleware! Between our operating system and applications!
Middleware classification
There are a lot of middleware. As early as 1998, IDC divided middleware into 6 categories. Many middleware related books published in China before 2005 are divided according to these 6 categories, respectively:
- Terminal emulation/screen conversion
- Data Access Middleware (UDA)
- Remote Procedure Call Middleware (RPC)
- Message-oriented middleware (MOM)
- Transaction Middleware (TPM)
- Object middleware
In addition to the message middleware and transaction middleware everyone here may have heard, other middleware estimates have seldom heard of, this is because The Times are changing, slowly eliminated some middleware (for example terminal emulation/screen conversion middleware), others slowly merged into other frameworks (for example Remote procedure call (RPC) middleware).
Database middleware
So what is database middleware?
As mentioned in the previous article, if the amount of data is relatively large, we need to divide the data into database and table. After dividing, the data originally stored in one database is now stored in multiple databases, so our project structure may be like the following:
We want to more complex configuration data source in Java code, the separation configuration, speaking, reading and writing, and data query and data preprocessing, such as from multiple DB is loaded into the data sorting, filtering and so on before operation, so our Java code mixed method that is independent of the many business and these mixed in the code, Most of them are repetitive.
To enable developers to focus more on the business, we introduce database middleware, like the following:
This chart is a very graphic illustration of what middleware is! Something in between two applications. After the introduction of MyCat middleware, our application will only need to connect MyCat on the line, and then MyCat to operate a variety of different DB, the sorting of each distributed database, result set and data filtering operations are completed in MyCat. In this way, our Java application can focus on business development again, and those tedious repetitive operations are handed over to MyCat to complete.
If there is no database middleware, so our Java application will directly face the shard cluster, data source switch, transaction processing, data aggregation, and so on many problems, so it’s a Java application to focus on business, will spend a lot of work to deal with the problem after the fragmentation, and most of the code is repeated again!
With database middleware, applications only need centralized business processing, a large number of general data aggregation, transactions, data source switching are handled by the middleware, the performance and processing ability of middleware will directly determine the application read and write performance, so it is very important to choose a good database middleware in the project.
conclusion
Ok, this article briefly introduces the basic concepts of middleware, and then we can officially start talking about distributed database middleware!
If friend feel scene oneself write technical articles will get by, welcome forward actively, scene every 15 days according to WeChat background data, choose a share most of a friend, to send a book scene his signature or Java in the field of classic books, welcome everyone to actively participate in, the next time next week.”
References:
- MyCat official documentation
- Zeng Xianjie. Large-scale Website System and Java Middleware Practice [M]. Beijing: Publishing House of Electronics Industry, 2014.
Pay attention to the public account [Jiangnan little Rain], focus on Spring Boot+ micro service and front and back end separation and other full stack technology, regular video tutorial sharing, after attention to reply to Java, get Songko for you carefully prepared Java dry goods!