| The Internet has become an integral part of people’s lives.However,this poses a severe challenge to the web server,which is an important part of Internet.How to improve the concurrency of web server has become an urgent problem.At present,horizontal expansion and vertical expansion have been used to solve the problem.However,horizontal expansion costs high.Besides,for vertical expansion,multi-process and multi-thread have limited effect and event driven is difficult.As a result,the existing methods are far from satisfactory.With the advent of the go language,people have rekindled the interest of the old concept,coroutine.Coroutine has some advantages,which are favorable factors for high concurrency.As a result,this paper uses it to improve the concurrency of web server.In this paper,we design a lightweight coroutine library for C language.This library is asymmetric.It uses the epoll model as the scheduler for web server because of web server’s characteristics.This library is stackful.It provides two models,stack model and heap model.It uses shared stack to solve the problem of limited space in stack model.This library has first-class object of language,which provides complete data structure and packaging.Experiments show that its performance is higher than the process and thread,and is same as mainstream coroutine library.In this paper,we use the coroutine library and reactor model to implement a high performance web server,which is composed of multi-process and coroutine.This web server is prototype.It uses multi-process to give full play to the advantages of multi-core CPU and uses coroutine to increase the concurrency of each process.This web server not only can parse static pages,but also can deal with PHP dynamic requests.The design of web server is modular.It is divided into 7 modules: log management module,configuration management module,process management module,coroutine management module,timer module,HTTP processing module and FASTCGI processing module.Experiments show that the web server runs well and performs better than Nginx and Apache. |