当前位置:网站首页>[swoole Series 1] what will you learn in the world of swoole?
[swoole Series 1] what will you learn in the world of swoole?
2022-07-01 23:23:00 【Ma Nong Lao Zhang ZY】
stay Swoole In the world of , What are you going to learn ?
In the next study , What we are going to touch , It will be PHP A very famous framework in the extension , That's it Swoole . Maybe you have used it in the production environment , Maybe you just read the official documents and wrote a few examples , Of course , More likely, you just heard its name .
Don't worry too much , Through our study , You will master the basic Swoole Development knowledge , Some simple knowledge of computer operating system and network , And a very similar Laravel Of Swoole frame . Believe that through these , You can try to use it in your real project Swoole To do some projects , Experience PHP A super strong solution to the most criticized efficiency problem .
Swoole
Let's take a look first Swoole What is it? .
Swoole send PHP Developers can write high-performance and high concurrency TCP、UDP、Unix Socket、HTTP、 WebSocket Etc , Give Way PHP No longer limited to Web field .Swoole4 The maturity of the collaborative process will PHP Into an unprecedented period , It provides a unique possibility for performance improvement .Swoole Can be widely used in the Internet 、 mobile communication 、 Cloud computing 、 Network game 、 The Internet of things (IOT)、 Car networking 、 Smart home and other fields . Use PHP + Swoole Can make the enterprise IT The efficiency of the R & D team has been greatly improved , More focus on developing innovative products .
The above paragraph is about Swoole Explanation . Looking at it, I feel tall ? Actually ,TCP、UDP、Unix Socket、HTTP、 WebSocket these , We are ordinary PHP Can also do , however , Usually we are doing ordinary Web When developing , With the help of a server application , for instance Apache perhaps Nginx To match fastcgi To implement . And in the Swoole in , Just run Swoole Services can realize the mounting of these services . Of course , We can also put it on the outside Nginx , This makes it easier to manage application addresses ( domain name ).
Besides , In the official description , High performance is a key word , To what extent can the performance be improved ? We will have an example demonstration later .
And traditional PHP Conceptual differences
Even if you haven't done it Java perhaps .NET、C/C++ And so on , I've heard that they need to be compiled to generate a running file before they can be officially deployed online . And our traditional PHP It seems that there is no such situation , Update a file at any time , Throw it on the server to run . This problem is about static and dynamic languages .
In general ,Java This kind of language can be summed up as static language , They have fixed variable types , You have to compile to run , The feature is that one load will directly load the code into memory . Typically, it's like various applications on our computers , Directly execute a program .exe file , This program runs on your computer . If you use a text tool to open this exe perhaps Java Of Jar Word of the file , What you will see is a pile of binary content like garbled code .
and PHP This kind of , Can be classified as dynamic language , The characteristic is that variables do not need to specify types , Any file can be run directly . I believe you must have thought of ,Python、JavaScript This is how it works . Even if JS Of npm compile , In fact, the code is only confused and formatted , Not fully compiled into a similar jar An intermediate code execution file like package .
For the compilation and operation mode of these two languages , Static languages load code into memory at one time , Efficiency will obviously improve a lot , After all, the speed gap between memory and hard disk is still quite large . and , Static languages will integrate many initial objects at once , Class template file loading , There is no need to reload instantiation when calling , Performance will have further room for improvement . however , Static languages usually need to be compiled into an executable intermediate file , If there are code updates , You must restart the whole program .
ok , The advantages and disadvantages of dynamic language are obviously the reverse of static language . Dynamic language runs one script at a time , You need to load all relevant files once , And if there is no other optimization ( such as OPcache), All relevant files should be read from the hard disk 、 Load memory 、 Instantiate these steps from the beginning . As one can imagine , Its efficiency and performance cannot be compared with static language . however , The advantages are also clear , Modify a file at any time, and you can go online at any time , Online business without interruption .
therefore ,PHP It is usually the first choice for start-ups , Because it's convenient , Fast update iteration , Little impact on online business . But when the company develops to a certain scale , But it is easy to be Java、Golang Wait for language to replace . After all , A server can resist 5 The pressure of servers , The cost can be saved a lot , More importantly , When the company reaches a certain scale , For hot updates 、 Standardize online and other related operations , It will also make problems such as the need for static languages to compile or restart services become marginal minor problems . Performance efficiency is often the more important consideration of large and medium-sized companies .
The above content is only based on my own understanding , Doesn't mean it's completely correct , But the general direction should be no problem . That must be the point , You can guess Swoole How to solve the problem of efficiency and performance . It is by loading code directly into memory , It's like Java They also start a process , Realization PHP High performance execution of code . meanwhile , Try to keep the code written in the traditional way , For us PHP Programmers provide a high-performance solution .
Tutorial framework
This series of tutorials is also in the form of articles and videos , We will divide it into two big modules .
The first module is based on official documents , Simply learn Swoole The contents of the framework , At the same time, try your best to explain some relevant computer and network knowledge .
The second module is one I use in the production environment Swoole frame Hyperf Relevant configurations of use . This frame is connected with Laravel Very similar , Good to start with . If you have chased our previous Laravel series , Then it should not be too difficult .
alike , There won't be too many actual projects , After all, these things are too much , Just search a bunch of .
References are also based on Swoole Official documents and Hyperf Based on official documents . Official documents are always the most important reference materials for you to learn , Not one of them. , What I wrote is just an extension of the official documents .
Last , There is also an explanation ,Swoole It was developed by our people : Han Tianfeng bosses . The document is in Chinese without pressure , similarly ,Hyperf It was also developed by Chinese leaders , The same pure Chinese document . Thank you guys !
summary
Okay , There's not much left to say , Let's hurry into Swoole In the world! .
ps. Due to limited personal level , In this series of article tutorials , If there is any mistake, please criticize and correct !
边栏推荐
- Daily three questions 6.29
- 认识线程
- MT manager test skiing Adventure
- Redis~02 缓存:更新数据时如何保证MySQL和Redis中的数据一致性?
- 建模和影视后期有什么关联?
- Force buckle 710 Random numbers in the blacklist
- 日本购物网站的网络乞丐功能
- Istio, ebpf and rsocket Broker: in depth study of service grid
- [micro service sentinel] @sentinelresource details
- Matplotlib common settings
猜你喜欢
[micro service sentinel] sentinel integrates openfeign
Notes on problems - /usr/bin/perl is needed by mysql-server-5.1.73-1 glibc23.x86_ sixty-four
问题随记 —— file /usr/share/mysql/charsets/README from install of MySQL-server-5.1.73-1.glibc23.x86_64 c
Matplotlib common settings
"35 years old, the boss of the company, with a monthly salary of 20000, give away takeout": the times abandoned you, not even saying goodbye
What professional classification does the application of Internet of things technology belong to
De PIP. Interne. CLI. Main Import main modulenotfounderror: No module named 'PIP'
Notes to problems - file /usr/share/mysql/charsets/readme from install of mysql-server-5.1.73-1 glibc23.x86_ 64 c
数字峰会人气火爆,城链科技引发新一轮商业变革
2022 R1 fast opening pressure vessel operation test questions and answers
随机推荐
Y53. Chapter III kubernetes from introduction to mastery -- ingress (26)
What professional classification does the application of Internet of things technology belong to
JS - use of arguments
每日三题 6.28
Practical application and extension of plain framework
Typescript enumeration
flutter Unable to load asset: assets/images/888. png
通过Go语言创建CA与签发证书
"35 years old, the boss of the company, with a monthly salary of 20000, give away takeout": the times abandoned you, not even saying goodbye
纪念成为首个DAYUs200三方demo贡献者
距离度量 —— 汉明距离(Hamming Distance)
Programming English vocabulary notebook
认识线程
[micro service sentinel] @sentinelresource details
数字峰会人气火爆,城链科技引发新一轮商业变革
CADD课程学习(3)-- 靶点药物相互作用
Rank ranking with MySQL 5.7
Understanding threads
每日三题 6.30
Convergence and disposal suggestions of some Internet exposure surfaces