In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article shows you how to understand process and event IO in Swoole. The content is concise and easy to understand. It will definitely make your eyes shine. I hope you can gain something from the detailed introduction of this article.
1. file lock
Child processes copy back the IO handle of the parent process, but you can't have all child processes operating on the same file at the same time, so you need file locks.
2. Communication between processes--pipes
A pipe is a set of 2 special descriptors
Pipes need to be created before fork function calls
If one section actively closes the pipe, the read operation at the other end will return 0 directly, and then the pipe will be closed.
When a pipe is created in a parent process, the parent process creates a set of descriptors; when a child process copies the parent process, it copies the set of descriptors.
3. Message Queue--A Way of Communication Between Processes
The advantage of using message queues over streaming pipes is that if a service goes down at one end, the data is not lost because the message is still in the queue
Message queues communicate much like shared memory
You can create a message queue by specifying a key
There is a limit on the size of data passed in message queues default 65535k
Message queues remain until they are actively closed
4. IO multiplexing
epoll listens to all socket descriptors registered under its own name
The epoll function responds only when a socket is interested in a time occurrence and returns a set of sockets with time occurrences.
The ability of epoll is to block IO, and the advantage is to be able to handle a large number of socket collections.
5. Event Loop Introduction
Event loop is a Reactor thread in which an epoll instance runs.
It can be added to the epoll listening of socket descriptor through interface, and the callback function of time response can be formulated.
Because Event Loop is a separate thread, it cannot be used in an fpm environment. Because fpm is a new process, it may be closed after the event, and scoket cannot be listened to.
After opening the Event loop, the program will start a thread and block on epoll's listening. After opening the Event loop, the program will run without stopping, which is also the intention of the swoole developers. The method of termination is to call the swoole_event_exit function.
6. SWOOL PROCESS
The swoole process consists of three parts: pipe, memory, and IO handle.
The swoole process has several advantages:
C language package is based on the management module to facilitate PHP multi-process programming;
Built-in pipeline, message queue interface, convenient to achieve inter-process communication;
Provide custom signal management
That's how you understand process and event IO in Swoole. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserves, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.