Java training-General java application architecture, java-java Architecture

Source: Internet
Author: User
Tags database sharding

Java training-General java application architecture, java-java Architecture

Java training-General java application architecture

1. Interaction between different systems and different languages

Now we commonly use WebService and Http requests for interaction between different systems and different languages. WebService, or "Web service", is abbreviated as WS. Literally, it is actually a "Web-based service ". The service is provided by both parties. If there is a service demand side, there will be a service provider. The service provider publishes services externally, and the service demander calls the Services published by the service provider. To be more professional, WS is actually a tool built on the HTTP protocol to implement heterogeneous system communication. That's right! WS is based on the HTTP protocol. That is to say, data is transmitted over HTTP. We first used CXF to develop the SOAP service to implement WS, followed by the REST service to implement WS (which is currently used a lot and most frequently used ). REST services can also be developed based on CXF. However, springMVC or other MVC frameworks are generally used to implement REST services.

However, many people think that Web services generally refer to various XML-based interaction technologies led by IBM more than a decade ago. Currently, few companies are using them. In a broad sense, Webservice is a Web service, and everything is a service.

2. Interaction between different systems in the same language

RPC (Remote Procedure Call) or RMI (remote method call) is used for common interaction between different systems in the same language, and external services are not required, of course, the above can also be used for interaction between the same language, but I usually use RPC.

  Architecture of different products

3. Architecture Evolution of a single product

Generally, we only have a product architecture evolution. If we need to provide external WebServices, we usually use REST services.

The following content comes from zhihu

1. Evolution of distributed architecture System Architecture Evolution History-Initial Stage Architecture

In the initial stage, all resources such as small system applications, databases, and files are stored on one server.

  Features: all resources such as applications, databases, and files are stored on one server.

Description: generally used by the server operating system.Linux, Application UsePHPDevelopment, and then deployed inApache, Database usageMysqlTo bring together a variety of free open-source software and a cheap server to start the development of the system.

2. Evolution of system architecture-separation of application services and data services

 

It is not a long time, and it is found that as the system traffic increases again, the pressure on the webserver machine will rise to a relatively high level during the peak period. At this time, we began to consider adding a webserver.

  Features: applications, databases, and files are deployed on independent resources.

Description: as the data volume increases and the performance and storage space of a single server is insufficient, applications and data must be separated, and the concurrent processing capability and data storage space must be greatly improved.

3. Evolution of system architecture-using cache to improve performance

 

  Features: a small portion of data in the database is stored on the cache server, reducing the number of database accesses and reducing the database access pressure.

Description: system access features follow the law, that is80%Business Access is concentrated in20%. Cache can be divided into local cache and remote distributed cache. Local cache access is faster, but the cache data volume is limited, and there is a situation of contention with applications for memory.

4. Evolution of system architecture-Use of Application Server Clusters

 

After database and table sharding, the pressure on the database has been reduced to a relatively low level. Then, I began to live a happy life of daily traffic surge. suddenly one day, we found that the system access started to slow down again. At this time, we first checked the database and the pressure was normal. Then we checked the webserver and found that apache blocked a lot of requests, the application server is also relatively fast for each request. It seems that the number of requests is too high, resulting in waiting in queues and slow response.

  Features: multiple servers provide external services through Server Load balancer to solve the problem of processing capacity and storage space ceiling of a single server.

Description: cluster is a common solution to high concurrency and massive data problems. By appending resources to the cluster, the system's concurrent processing capability is improved, so that the load pressure on the server is no longer the bottleneck of the entire system.

5. Evolution of system architecture-database read/write splitting

 

After enjoying the high-traffic growth of the system for a period of time, I found that the system began to slow down again. What is the situation this time, it is found that some database connection resources for database write and update operations are highly competitive, resulting in system slowdown.

  Features: multiple servers provide external services through Server Load balancer to solve the problem of processing capacity and storage space ceiling of a single server.

Description: cluster is a common solution to high concurrency and massive data problems. By appending resources to the cluster, the load pressure on the server is not the bottleneck of the entire system.

6. Evolution of system architecture-reverse proxy and CDN Acceleration

 

  Features: UseCDNAnd reverse proxy to speed up the systemAccess speed.

Description: To cope with complex network environments and access by users in different regionsCDNAnd reverse proxy to speed up user access and reduce the load pressure on backend servers.CDNThe basic principle of reverse proxy and proxy is cache.

7. Evolution of system architecture-Distributed File System and Distributed Database

 

As the system continues to run, the amount of data began to grow significantly. At this time, it was found that the query would still be slow after database sharding, so we started to do table sharding according to the concept of database sharding.

  Feature: Databases adopt distributed databases and file systems adopt distributed file systems.

Description: any powerful single server cannot meet the growing business needs of large systems. Database read/write splitting will not meet the demand as the business develops, distributed Databases and distributed file systems are required. Distributed databases are the final method for splitting system databases. They are used only when the data size of a single table is very large. The more common database sharding method is Business Database sharding, deploy different business databases on different physical servers.

8. Evolution of system architecture-using NoSQL and search engines

 

  Feature: SYSTEM INTRODUCTIONNoSQLDatabases and search engines.

Description: As the business becomes more and more complex, the requirements for data storage and retrieval become more and more complex. The system needs to use non-relational databases suchNoSQLAnd database-based query technologies such as search engines. The Application Server accesses various data through the Unified Data access module, which reduces the trouble for applications to manage many data sources.

9. Evolution of system architecture-Business splitting

 

  Feature: The system is split and transformed according to the business, and the application server is deployed separately according to the business distinction.

Description: To cope with increasingly complex business scenarios, the entire system business is usually divided into different product lines by means of separation and governance. Applications can establish relationships through hyperlinks or use message queues for data distribution, of course, more is to access the same data storage system to form an associated complete system. Vertical Split: A large application is split into multiple small applications. If the new business is relatively independent, it is directly designed and deployed as an independentWebVertical splitting of application systems is relatively simple. You can simply sort out a small number of related services. Horizontal Split: the reusable services are split and independently deployed as distributed services. To add new services, you only need to call these distributed services for horizontal split. You need to identify reusable services and design service interfaces, standardize service dependencies.

10. Evolution of system architecture-distributed services

 

  Feature: common application modules are extracted and deployed on distributed servers for the application server to call.

Description: As the business is smaller and smaller, the overall complexity of the application system increases exponentially. As all applications need to connect to all database systems, database connection resources are insufficient and services are rejected.

  Q: What problems do distributed service applications face?

(1) As there are more and more services, it is very difficult to manage Service URL configurations, and the single point of pressure on F5 hardware Server Load balancer is also increasing.
(2) As the dependency between services becomes more complex, architects cannot fully describe the architecture relationship of an application until the application is started.
(3) then, as the number of calls to the service increases, the capacity of the Service is exposed. How many machines does the service need to support? When should I add machines?
(4) When there are more services, communication costs also begin to rise. Who should I find if a service fails to be called? What are the conventions for service parameters?
(5) How to ensure service quality when a service has multiple business consumers?
(6) with the continuous upgrading of services, there are always some unexpected events, such as memory overflow caused by cache errors, and failures are inevitable. Each time the core service crashes, it affects a large part, people are panic. How can we control the impact of faults? Can the service function be downgraded? Or resource degradation?
This seems to be the beginning of the core principles and case analysis of large-scale website technical architecture, but the author has summarized it well and I will repost it.

4. Product Line Architecture

There is also the business splitting mentioned above. Now we need to build a product line. We only need a data layer, a general business logic layer, and a variety of application and interface layers, without external systems (external company systems) before providing services, we usually choose to use EJB to build distributed applications, however, now we can use RPC frameworks such as dobbo, thrift, avro, and hessian to build distributed applications for interaction between different applications and data sources. In this structure mode, we need to provide services to other companies. We can write an application to provide rest services to external systems. Generally, most Internet services require access to dozens or even hundreds of internal services. The communication methods between these services are generally RPC: Just like accessing a remote method, enter parameters and wait for the returned results. This is the easiest way to understand building complex systems.

For example, if the model, file system, and cache are not drawn, you can understand it.

 

Conclusion:

No matter which architecture we need to modularize (try to reuse modules as much as possible ).
Do not over-design the architecture for the sake of architecture.
No matter what architecture is to better meet business needs, the architecture should follow the development of the business.
If the current architecture can meet the current business development needs, you can consider the next step of expansion. You don't have to consider three steps, four steps, or more at once.
If the above error is correct, I hope you will not be enlightened!

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.