问个有关问题哟 不知道如何标题应该如何取
问个问题哟 不知道怎么标题应该怎么取
就当时标题党吧
服务器上有一个php 文件 比如是1.php
当别人请求这个文件的时候
这个文件就会被执行 然后返回给客户端执行后的东西
我的问题是
当a客户访问的时候1.php的时候 这是服务器还没有执行完,
突然后b客户也来访问了 这是1.php是等返回了a的请求在执行b的请求了,还是可以同时执行b的请求
------解决方案--------------------
同时执行b的请求
------解决方案--------------------
其实这涉及到网络模型的问题了。
你知道为什么现在都推崇nginx来取代apache,为什么nginx处理并发问题比apache要强很多吗?
因为apache采用的是linux旧版本内核的select模型,而nginx采用的是2.6+版本的epool模型。
回到具体你说的这个问题上,如果b客户来访问时,服务器等待a客户的处理结果再接受b的请求,这就是select模型的工作方式。从接收到请求后之后,同一个进程会一直follow这整个握手过程,知道response结束。这种模型也很容易遭到ddos攻击。
而epool模型,是异步的。服务器接收到一个请求后,由一个主进程负责把任务合理分工开,有个负责分发任务的线程只负责分发任务,剩余的事情委托给其他线程去处理,其他线程处理完毕后,会callback一下主进程可以response了,然后返回给相应客户端。这样的工作方式,每个请求都不会相互阻塞。
不过这样解释后,你可能会不明白,难道说apache就没法处理并发任务了?一个请求阻塞了,其他的请求都进不来了?当然不是,apache worker模式下会开n个进程,所谓的阻塞,也只会阻塞住一个进程。但select模型的这种工作方式确实效率很低。
这部分知识,你可以去参考libevent

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP is suitable for web development and content management systems, and Python is suitable for data science, machine learning and automation scripts. 1.PHP performs well in building fast and scalable websites and applications and is commonly used in CMS such as WordPress. 2. Python has performed outstandingly in the fields of data science and machine learning, with rich libraries such as NumPy and TensorFlow.

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

IIS and PHP are compatible and are implemented through FastCGI. 1.IIS forwards the .php file request to the FastCGI module through the configuration file. 2. The FastCGI module starts the PHP process to process requests to improve performance and stability. 3. In actual applications, you need to pay attention to configuration details, error debugging and performance optimization.

NGINX and Apache each have their own advantages and disadvantages, and the choice should be based on specific needs. 1.NGINX is suitable for high concurrency scenarios because of its asynchronous non-blocking architecture. 2. Apache is suitable for low-concurrency scenarios that require complex configurations, because of its modular design.
