Jump to content

Great Results with Nginx Cache


Recommended Posts

  • Replies 112
  • Created
  • Last Reply

yeah I had this issue before nginx was used which is why I asked, can't remember if turning off minfy or turning off load js from google servers fixed it for me.
may be worth experimenting with those real quick with nginx running to see.

Link to comment
Share on other sites

I use NGINX + FPM and have no issues editing posts, but ever since switching back from Apache and upgrading PHP to 5.4.3, I've been unable to use the "ban" button in the ACP. I can still suspend and warm members outside of the ACP, but this is a weird little glitch I haven't fully looked into.

Anyways, interesting guide, I may have to mess around with it a bit sometime soon.

Link to comment
Share on other sites

Hi,

Just to say that I already have a functional purge solution working in my test board that do the follow:

On New Topic, the forum is purged
On New Reply, both forum and topic is purged
On Fast Reply, both forum and topic is purged

Just need to test a little bit more and then I post it!

Link to comment
Share on other sites

  • 2 weeks later...

Nginx caching looks good :smile:. Here are some rough numbers:
Apache + Mod_php + APC = ~35req/sec
Nginx + PHP-FPM + APC = ~37req/sec
Nginx + Caching + PHP-FPM + APC = ~657req/sec

so 18x improvement. Aint bad. Also for the record when i had 500 concurrent users the load was
Apache = ~99 load (Apache died with 500 concurrent, had to drop to 100 and got this load)
Nginx = ~47 load
Nginx Cache = ~0.14 load

Hopefully Nuno can help us out with purging of the cache.



[root@BZ-1 ~]# ab -n 10000 -c 100 -H 'Host: www.bellazon.com' http://192.168.50.2/main/index.php

This is ApacheBench, Version 2.3 <$Revision: 655654 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.50.2 (be patient)

Completed 1000 requests

Completed 2000 requests

Completed 3000 requests

Completed 4000 requests

Completed 5000 requests

Completed 6000 requests

Completed 7000 requests

Completed 8000 requests

Completed 9000 requests

Completed 10000 requests

Finished 10000 requests


Server Software:	 Apache/2.2.22

Server Hostname:	 192.168.50.2

Server Port:		 80

Document Path:		 /main/index.php

Document Length:	 177931 bytes

Concurrency Level:	 100

Time taken for tests: 290.381 seconds

Complete requests:	 10000

Failed requests:	 90

(Connect: 0, Receive: 0, Length: 90, Exceptions: 0)

Write errors:		 0

Total transferred:	 1783520180 bytes

HTML transferred:	 1779310180 bytes

Requests per second: 34.44 [#/sec] (mean)

Time per request:	 2903.808 [ms] (mean)

Time per request:	 29.038 [ms] (mean, across all concurrent requests)

Transfer rate:		 5998.05 [Kbytes/sec] received

Connection Times (ms)

			 min mean[+/-sd] median max

Connect:	 0 0 0.2	 0	 2

Processing: 296 2898 245.0 2937 3519

Waiting:	 216 2800 239.0 2836 3385

Total:	 296 2899 245.0 2937 3520

Percentage of the requests served within a certain time (ms)

50% 2937

66% 3013

75% 3058

80% 3085

90% 3156

95% 3213

98% 3272

99% 3319

100% 3520 (longest request)


[root@BZ-1 ~]# ab -n 400 -c 8 -H 'Host: www.bellazon.com' http://192.168.50.2/main/index.php

This is ApacheBench, Version 2.3 <$Revision: 655654 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.50.2 (be patient)

Completed 100 requests

Completed 200 requests

Completed 300 requests

Completed 400 requests

Finished 400 requests


Server Software:	 Apache/2.2.22

Server Hostname:	 192.168.50.2

Server Port:		 80

Document Path:		 /main/index.php

Document Length:	 177931 bytes

Concurrency Level:	 8

Time taken for tests: 10.814 seconds

Complete requests:	 400

Failed requests:	 0

Write errors:		 0

Total transferred:	 71340800 bytes

HTML transferred:	 71172400 bytes

Requests per second: 36.99 [#/sec] (mean)

Time per request:	 216.284 [ms] (mean)

Time per request:	 27.036 [ms] (mean, across all concurrent requests)

Transfer rate:		 6442.33 [Kbytes/sec] received

Connection Times (ms)

			 min mean[+/-sd] median max

Connect:	 0 0 0.1	 0	 1

Processing: 200 215 8.3 213	 250

Waiting:	 192 204 7.7 202	 236

Total:	 201 215 8.3 213	 250

Percentage of the requests served within a certain time (ms)

50% 213

66% 217

75% 219

80% 222

90% 227

95% 231

98% 239

99% 241

100% 250 (longest request)





############################### NGINX ######################################################

[root@BZ-1 ~]# ab -n 400 -c 8 -H 'Host: www.bellazon.com' http://192.168.50.2/main/index.php															 This is ApacheBench, Version 2.3 <$Revision: 655654 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.50.2 (be patient)

Completed 100 requests

Completed 200 requests

Completed 300 requests

Completed 400 requests

Finished 400 requests


Server Software:	 nginx/1.2.1

Server Hostname:	 192.168.50.2

Server Port:		 80

Document Path:		 /main/index.php

Document Length:	 177942 bytes

Concurrency Level:	 8

Time taken for tests: 10.706 seconds

Complete requests:	 400

Failed requests:	 0

Write errors:		 0

Total transferred:	 71327200 bytes

HTML transferred:	 71176800 bytes

Requests per second: 37.36 [#/sec] (mean)

Time per request:	 214.124 [ms] (mean)

Time per request:	 26.765 [ms] (mean, across all concurrent requests)

Transfer rate:		 6506.09 [Kbytes/sec] received

Connection Times (ms)

			 min mean[+/-sd] median max

Connect:	 0 0 0.1	 0	 1

Processing: 193 212 24.9 205	 405

Waiting:	 185 203 24.8 196	 391

Total:	 194 212 24.9 206	 405

Percentage of the requests served within a certain time (ms)

50% 206

66% 210

75% 214

80% 217

90% 225

95% 239

98% 292

99% 381

100% 405 (longest request)



[root@BZ-1 ~]# ab -n 10000 -c 100 -H 'Host: www.bellazon.com' http://192.168.50.2/main/index.php

This is ApacheBench, Version 2.3 <$Revision: 655654 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.50.2 (be patient)

Completed 1000 requests

Completed 2000 requests

Completed 3000 requests

Completed 4000 requests

Completed 5000 requests

Completed 6000 requests

Completed 7000 requests

Completed 8000 requests

Completed 9000 requests

Completed 10000 requests

Finished 10000 requests


Server Software:	 nginx/1.2.1

Server Hostname:	 192.168.50.2

Server Port:		 80

Document Path:		 /main/index.php

Document Length:	 177942 bytes

Concurrency Level:	 100

Time taken for tests: 284.865 seconds

Complete requests:	 10000

Failed requests:	 46

(Connect: 0, Receive: 0, Length: 46, Exceptions: 0)

Write errors:		 0

Total transferred:	 1783180092 bytes

HTML transferred:	 1779420092 bytes

Requests per second: 35.10 [#/sec] (mean)

Time per request:	 2848.647 [ms] (mean)

Time per request:	 28.486 [ms] (mean, across all concurrent requests)

Transfer rate:		 6113.03 [Kbytes/sec] received

Connection Times (ms)

			 min mean[+/-sd] median max

Connect:	 0 0 0.3	 0	 5

Processing: 243 2840 275.8 2876 4485

Waiting:	 235 2795 263.2 2832 3391

Total:	 245 2840 275.6 2876 4485

Percentage of the requests served within a certain time (ms)

50% 2876

66% 2952

75% 2998

80% 3025

90% 3100

95% 3157

98% 3230

99% 3281

100% 4485 (longest request)


############### Nginx Cacheing ########################

[root@BZ-1 ~]# ab -n 400 -c 8 -H 'Host: www.bellazon.com' http://192.168.50.2/main/index.php

This is ApacheBench, Version 2.3 <$Revision: 655654 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.50.2 (be patient)

Completed 100 requests

Completed 200 requests

Completed 300 requests

Completed 400 requests

Finished 400 requests


Server Software:	 nginx/1.2.1

Server Hostname:	 192.168.50.2

Server Port:		 80

Document Path:		 /main/index.php

Document Length:	 178041 bytes

Concurrency Level:	 8

Time taken for tests: 0.608 seconds

Complete requests:	 400

Failed requests:	 0

Write errors:		 0

Total transferred:	 71370400 bytes

HTML transferred:	 71216400 bytes

Requests per second: 657.37 [#/sec] (mean)

Time per request:	 12.170 [ms] (mean)

Time per request:	 1.521 [ms] (mean, across all concurrent requests)

Transfer rate:		 114542.93 [Kbytes/sec] received

Connection Times (ms)

			 min mean[+/-sd] median max

Connect:	 0 1 0.2	 1	 1

Processing:	 7 11 0.7	 11	 13

Waiting:	 0 1 0.2	 1	 2

Total:		 8 12 0.6	 12	 13

Percentage of the requests served within a certain time (ms)

50%	 12

66%	 12

75%	 13

80%	 13

90%	 13

95%	 13

98%	 13

99%	 13

100%	 13 (longest request)

[root@BZ-1 ~]# ab -n 10000 -c 500 -H 'Host: www.bellazon.com' http://192.168.50.2/main/index.php

This is ApacheBench, Version 2.3 <$Revision: 655654 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.50.2 (be patient)

Completed 1000 requests

Completed 2000 requests

Completed 3000 requests

Completed 4000 requests

Completed 5000 requests

Completed 6000 requests

Completed 7000 requests

Completed 8000 requests

Completed 9000 requests

Completed 10000 requests

Finished 10000 requests


Server Software:	 nginx/1.2.1

Server Hostname:	 192.168.50.2

Server Port:		 80

Document Path:		 /main/index.php

Document Length:	 178041 bytes

Concurrency Level:	 500

Time taken for tests: 15.235 seconds

Complete requests:	 10000

Failed requests:	 0

Write errors:		 0

Total transferred:	 1788370654 bytes

HTML transferred:	 1784508334 bytes

Requests per second: 656.38 [#/sec] (mean)

Time per request:	 761.758 [ms] (mean)

Time per request:	 1.524 [ms] (mean, across all concurrent requests)

Transfer rate:		 114633.25 [Kbytes/sec] received

Connection Times (ms)

			 min mean[+/-sd] median max

Connect:	 5 65 146.4	 49 3057

Processing: 259 686 240.2 597 2660

Waiting:	 4 55 38.6	 50	 558

Total:	 269 751 280.0 646 3857

Percentage of the requests served within a certain time (ms)

50% 646

66% 653

75% 836

80% 903

90% 1054

95% 1260

98% 1647

99% 1888

100% 3857 (longest request)

Link to comment
Share on other sites


are you using any htaccess for furls (per the acp settings) and if so how?




I have the following:
Redirect to Friendly URL: YES
URL Type: Query String
.htaccess mod_rewrite: NO

I have .htaccess to NO since there is no such thing in Nginx. I just need to figure out how to get rid of the index? part in www.domain.com/main/index?/forum/59-legal/

I will let you know if I figure that one out, I am new to Nginx so its just a lot of googling and trial and error.
Link to comment
Share on other sites


I have the following:


Redirect to Friendly URL: YES


URL Type: Query String


.htaccess mod_rewrite: NO



I have .htaccess to NO since there is no such thing in Nginx. I just need to figure out how to get rid of the index? part in www.domain.com/main/[color=#ff0000]index?[/color]/forum/59-legal/



I will let you know if I figure that one out, I am new to Nginx so its just a lot of googling and trial and error.




thanks all, that was why I was wondering due to htaccess and nginx.


about to try nginx on directadmin server and am reading up on stuff prior.



http://community.invisionpower.com/topic/332591-apache-vs-nginx-vs-lighttpd/#entry2200234
Link to comment
Share on other sites

Htaccess is an Apach thing. Apache actually recommends disabling the use of .htaccess where possible, and instead recmmends you use the Apache configuration files directly. .htaccess is simply a unnececery performance overhead when you're using your own dedicated server, but is useful for shared hosting.

If you want to use friendly URL's, you wil need to enable .htaccess in the ACP and use the try_files trick I linked to, even on NGINX, and even though it "doesn't exist" in NGINX.

I'm actually using Apache right now, due to complications with PHP-FPM.

My server is powerful enough that the performance gains are negligable. I only get around 5,000-6,000 visitors a day anyways.

Link to comment
Share on other sites

I loved apache, simple to use and plenty of info out there to fix any problem you may have. The only reason I have considered moving to Nginx was because my server (dual quad xeons, 24gb ram, 4x512GB SSDs) is for the caching, during low traffic periods (300-500 users online) MySQL returns all pages in < 1 sec. Once users are 800+ pages start to slow down to 2.5-3sec range (although most are still <1sec). Hopefully with caching MySQL is never taxes and its always < 1sec (or faster).

I considered Apache + Varnish but never got around to truly testing it. Perhaps I will give it another go and posts some results if I can get it to work correctly, but Nginx seems like only 1 thing to maintain vs two with Apache + Varnish.

Link to comment
Share on other sites


http://community.inv...d/#entry2200234




Josh,

You said to put it in the location block? I used Nuno's config and I put it in there and nothing happens. I tried it in the root of the Server block and that didnt work either. Can you let us know where it belongs in Nuno's script (http://community.inv...e/#entry2276815)? Thanks.


try_files $uri $uri/ /index.php?$args;

Link to comment
Share on other sites


Josh,



You said to put it in the location block? I used Nuno's config and I put it in there and nothing happens. I tried it in the root of the Server block and that didnt work either. Can you let us know where it belongs in Nuno's script (

http://community.inv...e/#entry2276815

)? Thanks.




try_files $uri $uri/ /index.php?$args;[/CODE]

[code] location / { index index.php; try_files $uri $uri/ /index.php?$args; }

Yes, it should go in your location block.

Link to comment
Share on other sites


Did you have to enable the .htaccess rules in the ACP?



If I put it here:



			 ## Main location

			 location / {

#					 try_files $uri $uri/ /index.php;

try_files $uri $uri/ /index.php?$args;

			 }



It still shows up with index.php?/

If I enable the .htaccess in APC it removes it but then the pages dont load.


Yes, you need to enable .htaccess.

If you want to use friendly URL's, you wil need to enable .htaccess in the ACP and use the try_files trick I linked to, even on NGINX, and even though it "doesn't exist" in NGINX.



Do you just get a white screen of death? (A blank white page)

If so, can you check your error log and see why the pages won't load?

Also, are you using Query String or Patch Info as your URL type? (You can see this setting on the same page that you enable .htaccess)
Link to comment
Share on other sites

query_string

And its not a white page, its actually going back to the root index.php (Hello World) page I have. After removing the index.php on the root it gets 404 not found.

So just to clarify my forum is under www.domain.com/main/index.php. When I put in your changes it goes to www.domain.com/index.php regardless of what page I

Link to comment
Share on other sites


query_string



And its not a white page, its actually going back to the root index.php (Hello World) page I have. After removing the index.php on the root it gets 404 not found.



So just to clarify my forum is under www.domain.com/main/index.php. When I put in your changes it goes to www.domain.com/index.php regardless of what page I



Ah, I think I see the problem in.

Hmm. Maybe try this, then?


## Main location

location / {

# try_files $uri $uri/ /main/index.php;

try_files $uri $uri/ /main/index.php?$args;

}


I'm not sure if this will actually work, since it may try and parse the "/main" part as the URI itself, but, it's worth a shot.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...