Home  >  Article  >  Backend Development  >  How to handle high concurrency of big data in PHP

How to handle high concurrency of big data in PHP

(*-*)浩
(*-*)浩Original
2019-11-12 17:36:303585browse

How to handle high concurrency of big data in PHP

Big data solution

Use cache: (Recommended learning: PHP video tutorial )

How to use: 1. Use the program to save directly into the memory. Mainly use Map, especially ConcurrentHashMap.

Use caching framework. Commonly used frameworks: Ehcache, Memcache, Redis, etc.

The most critical question is: when to create the cache and its invalidation mechanism.

For the buffering of empty data: It is best to save it with a specific type value to distinguish between empty data and uncached states.

Distributed database

Store different tables in different databases, and then put them on different servers. Some complex problems, such as transaction processing and multi-table query.

NoSql and Hadoop

NoSql, not only SQL. It does not have as many restrictions as relational databases and is more flexible and efficient.

Hadoop layers the data in a table into multiple blocks and saves it to multiple nodes (distributed). Each piece of data is stored on multiple nodes (cluster). Clusters can process the same data in parallel and ensure data integrity.

High concurrency solution

Separate applications and static resources.

Put static resources (js, css, pictures, etc.) into a dedicated server.

Page caching

Cache the pages generated by the application to save a lot of CPU resources.

For some pages that frequently change data, you can use ajax to process it.

Cluster and distributed

Cluster, multiple servers have the same functions and mainly play the role of diversion.

Distributed, putting different businesses on different servers. Multiple servers may be needed to process a request, thereby increasing the processing speed of a request.

It is divided into static resource cluster and application cluster. The latter is more complicated, and issues such as session synchronization often need to be considered.

Reverse proxy

The server that the client directly accesses is not the server that directly provides services. It obtains resources from other servers and then returns the results to the user.

CDN

CDN is a special cluster page cache server. Compared with multiple page cache servers in an ordinary cluster, the main difference is: its storage location and Allocate requests differently.

CDN servers are distributed across the country. After receiving a request, it will be assigned to the most appropriate CDN server node to obtain the data. Each of its CDN nodes is a page caching server.

The above is the detailed content of How to handle high concurrency of big data in PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn