Home  >  Article  >  Backend Development  >  php 数据库连接性能有关问题

php 数据库连接性能有关问题

WBOY
WBOYOriginal
2016-06-13 13:07:09734browse

php 数据库连接性能问题
刚开始学习php,但是有个问题搞不明白
php是一个用户访问页面就与数据库建立一个连接,可是如果连接数比较大,那不是
性能很低吗。php里有类似连接池这个概念吗,就是分配一定数量的连接,然后重复
使用。求高手指教!

------解决方案--------------------
为什么连接数大就会性能低呢?
mysql默认连接数是100,就是说1个连接与100个连接的性能是一样的
apache默认连接数是150,除非你的网页中只是单一的数据查询(没有图片和外联样式表),才有可能出现150个访问中有50个排队(指150个用户在同一时刻发出请求)

连接池并不缓存数据库连接,他缓存的是到数据库服务器的网络连接
php虽然不提供连接池,但他提供了长连接用来缓存到数据库服务器的网络连接

注意,连接池并不是编程语言提供的,而是由第三方提供的应用软件:jdbc、odbc的附属功能

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn