博文

目前显示的是 八月, 2017的博文

Enabling Nginx mod_rewrite | DigitalOcean

Enabling Nginx mod_rewrite | DigitalOcean https://www.digitalocean.com/community/questions/enabling-nginx-mod_rewrite

apache网站访问缓慢的处理记录

朋友在阿里云上开通了一台ubuntu服务器(2G内存,2核CPU),用apache搭建了一个公众号网站。 网站初期,他没有做相应的优化,在后续公众号推广活动时,网站并发突增,访问十分缓慢 。 登陆服务器,具体现象为: 1)uptime查看负载较高; 2)ss -a(或netstat命令) 查看连接数较多,并且WAIT_TIME比较多 ; 3) apache日志显示prefork工作模式下的并发连接数设置有问题 ;[mpm_prefork:error] [pid 13848] AH00161: server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting 4)重启apache服务后,网站暂时访问稍快,但过一会后又十分缓慢。 针对上面的现象, 帮他做了一些优化操作后,网站高并发下访问正常,速度很快 。操作记录如下: 1)修改apache的最大并发连接数(默认是256) 有日志报错可知,apache采用的是默认的prefork模式(使用apache2 -l或httpd -l命令也能查看处理 ) 找到mpm_prefork.conf文件进行连接数的修改(若是work模式,就修改mpm_worker.conf) [root@wang ~]# vim /etc/apache2/mods-available/mpm_prefork.conf       StartServers                     10       MinSpareServers               10       MaxSpareServers              20       ServerLimit             ...

Check Apache bottle neck

You first need to determine what is the root-cause of things running slowly. I suggest to  strace  the apache process like this: First, determine the process id of the parent apache process by running: $ ps axu | grep apache | grep root The first number in the output (2nd field) should list the process-id. Output example: root 9446 0.0 0.0 255620 15124 ? Ss Aug02 0:06 /usr/sbin/apache2 -k start Now  strace  the process and its children processes like this: $ sudo strace -f -p 9446 -T (make sure to replace the process id  9446  by your actual process id as revealed by the 1st command.) The output will list all system calls followed by the time it took them to complete. It should make it very clear where are you spending your time or getting stuck. Please note that system calls that are blocking by nature, like  select  or  accept  would normally block until an external event occurs, so they are expected to not return ...