Looking for breakthrough ideas for innovation challenges? Try Patsnap Eureka!

Method for processing high-concurrency IO based on PHP

An asynchronous processing and threading technology, applied in electrical digital data processing, program startup/switching, inter-program communication, etc., can solve problems such as wasting CPU resources, solve the problem of frightening herds, improve IO processing capabilities, and solve performance bottlenecks. Effect

Pending Publication Date: 2020-02-14
武汉智美互联科技有限公司
View PDF3 Cites 9 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

But there is still a problem with select / poll: select / poll needs to loop to detect whether there is an event on the connection
At this point, if the server has 1 million connections, and only one connection sends data to the server at a certain time, select / poll needs to be looped 1 million times, of which only 1 is a hit, and the remaining 999999 times are invalid Yes, wasting CPU resources in vain

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • Method for processing high-concurrency IO based on PHP
  • Method for processing high-concurrency IO based on PHP
  • Method for processing high-concurrency IO based on PHP

Examples

Experimental program
Comparison scheme
Effect test

Embodiment

[0057] The scheduling of threads and processes is regulated by the operating system, while the scheduling of coroutines is regulated by the user. The coroutine scheduler of swoole can suspend the coroutine before coroutine A is about to enter the blocking IO operation, such as socket read (actually set to asynchronous IO), save the current stack information StackA, and then Switch to coroutine B, wait until the IO operation of coroutine A returns, and then switch back to the previous state of coroutine A at that time according to StackA.

[0058] S4. End the coroutine:

[0059] When the callback function is executed, the coroutine is terminated through the coro_close method.

[0060] The advantages of the present invention are:

[0061] The present invention uses the Swoole model, adds a multi-process Worker through a multi-threaded Reactor model (based on epoll), creates a coroutine in each thread, and processes IO tasks asynchronously through the coroutine scheduling, that i...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

PUM

No PUM Login to View More

Abstract

The invention discloses a method for processing high-concurrency IO based on PHP. The method comprises: Swoole creating one or more processes according to configuration; the Master process creating NReactor threads; creating a coroutine in each Reactor thread; and asynchronously processing the IO task through coroutine scheduling. According to the invention, a Swoole model is used, through the multi-thread Reactor model (based on epoll) and a multi-process Worker, a coroutine is created in each thread. Through coroutine scheduling, an IO task is asynchronously processed, namely, when meetingthe condition of IO time consumption, firstly processing other code logics through coroutine scheduling until IO is completed and then continuing to execute previous codes; according to the method, system resources are fully utilized, IO blockage waiting and system resource waste are reduced, the IO processing capacity under high concurrency is greatly improved, and the problems of Accept performance bottleneck and convulsion group can be solved.

Description

technical field [0001] The invention relates to the technical field of high concurrent IO processing, in particular to a method for processing high concurrent IO based on PHP. Background technique [0002] High concurrency usually refers to processing many requests in parallel at the same time, which is one of the factors that must be considered in the design of distributed system architecture. When the system takes too long to respond to requests, the user experience of Internet products will be greatly reduced. [0003] In the Internet era, high concurrency usually refers to concurrent access, that is, how many accesses come at the same time at a certain point in time. Usually, the daily PV of a system is more than 10 million, which may be a highly concurrent system. [0004] At present, most of the concurrent IO solutions use IO multiplexing technology. Linux has long provided the select system call, which can maintain 1024 connections in one process. Later, the poll s...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

Application Information

Patent Timeline
no application Login to View More
Patent Type & Authority Applications(China)
IPC IPC(8): G06F9/54G06F9/48
CPCG06F9/546G06F9/4806
Inventor 鲁曦
Owner 武汉智美互联科技有限公司
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Patsnap Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Patsnap Eureka Blog
Learn More
PatSnap group products