Jump to content

Great Results with Nginx Cache


Recommended Posts

Hi,

Yes, I'm using the same config, but I'm evaluating too a solution where you have nginx(1):80 -> varnish:6081 -> nginx(2):8080 ... nginx sandwich.

nginx(1) get the requests from the end user and send (proxy) php requests to varnish .. static files are served directly by nginx(1)

vanish receives the request and sent then to the backend nginx(2)

nginx(2) executes the php files with php-fpm help and return the results to varnish

varnish decide what to do and returns the result do nginx(1)

nginx(1) send the page to the client browser.

It's an orthodox solution but I like it because:

  • we don't have to place varnish in port 80, so if you have multiple hosts in the same server you can decide which ones can use varnish
  • static files are served faster from nginx(1) than from varnish, so this is a must
  • varnish can clean cookies better than nginx, resulting in a more secure setup.
  • we can have long ttl's since we can purge varnish cache better than nginx cache
  • guest sessions are removed from headers and we only need to edit two files to remove javascript session_id from IPB generated pages to guests, resulting in a more secure setup.
Link to comment
Share on other sites

  • Replies 112
  • Created
  • Last Reply

That sounds like a crazy setup, I like :smile:

Do you have any real world performance charts where you can see the changes in performance in your website? Cacti or something? Did you notice a diff when you went varnish to nginx or implemented caching or anything?

A small test using gomez I can see these values

Without Cache:

Total Response Time: 1.143
Total Bytes: 714580
With Cache:
Total Response Time: 0.895
Total Bytes: 738856
These numbers say I have have less 20% time for loading my board index
Using webpagetest I can see almost 30% reduce.
Link to comment
Share on other sites

I agree with you, adding the session to the key is a secure measure that avoids session hijacked but defeats the cache propose, since you are caching the same page n times the number of users that visit this page ...

I would prefer a way to remove the session cookie for guests, maybe a mod!

I reported the session problem as a bug but it was ignored. Please help by posting your support there so they take it seriously!

While it's true that session-bound caching seems counter-productive since each guest will get served up a different page, for a high traffic environment where a lot of users log in the session hijacking risk is too much of a problem.

Yes, I'm using the same config, but I'm evaluating too a solution where you have nginx(1):80 -> varnish:6081 -> nginx(2):8080 ... nginx sandwich.

I think that's a very redundant method just to avoid the session mess caused by the IPB developers.

Link to comment
Share on other sites

  • 1 month later...

Hi,

I agree with you, adding the session to the key is a secure measure that avoids session hijacked but defeats the cache propose, since you are caching the same page n times the number of users that visit this page ...

I would prefer a way to remove the session cookie for guests, maybe a mod!

Parisians Config?:

So will parisians setup not yield any benefits in its current config(without guest sessions disabled)?

Nunos Config?

And would Nunos setup be considered unsecure?

Nuno I notice you mention SSI in the first post and then in a later post you mentioned you never ended up setting it up? So does the SSI script from the first post work properly? Are their any drawbacks to this method of topic caching?

I reported the session problem as a bug but it was ignored. Please help by posting your support there so they take it seriously!

While it's true that session-bound caching seems counter-productive since each guest will get served up a different page, for a high traffic environment where a lot of users log in the session hijacking risk is too much of a problem.


I think that's a very redundant method just to avoid the session mess caused by the IPB developers.

Getting IPS to integrate improvements:

IPS seems to feel differently about what is and isn't a bug, if its performance improvement related, they pretty much qualify it as feedback. Post either a new IP.Board feedback thread, However it took me almost a year to get one major suggestion pushed through and confimed, and it actually got pushed through after I gave up on it because of all the community resistance(certain changes are tougher for people to want to accept) "Attachments in Fast Reply"

Alternatively you can suggest that in an IPB 4.0 Performance thread that I have running that seems to have gained a little momentum:

IPB 4.0 is our opportunity to get IPS to consider alot of performance/scaling problems were currently facing so if we can identify the best methods to implement something and it is dubbed safe/secure, I'm sure they will integrate it. They've already committed to integrating better cdn support for minified files. I would honestly love to see nginx and varnish natively supported as a caching mechanism, with proper storage/flushing of cache controlled by ipboard core.

Disable Guest Cookie, thats it?

Is all thats needed for a clean nginx cache is the ability to disable guest cookie? Also what problems could guests have if this cookie is removed/disabled?

Logged in User cacheable in any way(via nginx cache)?:

Last question, what if anything can we do to nginx cache logged in users? Is their anything we can cache for them safely to improve performance for them? (the only reason I ask is because I have alot of international members, so I'd love to improve their performance as best I can as well.)

Hook/Mod Able?

Also can this be done with a simple mod? And can SSI support be done with a simple mod as well?

I know this is about 10+ questions, but if I can get the correct answers I can see if I can get our plugin dev[Esther with HeadStandConsulting] to quote me on how much a mod/hook to do this properly would cost.

Link to comment
Share on other sites

Hello,

I never tested SSI ... this is just a theory.

Regarding session_id for guests, I made a simple hook that I haven't placed in the market but you can test form your self (attach).

You should then edit "includeVars" in "skin_global" and replace:

ipb.vars['secure_hash']  = '{$this->member->form_hash}';
ipb.vars['session_id'] = '{$this->member->session_id}';

with:

<if test="$this->memberData['member_id']">
ipb.vars['secure_hash']  = '{$this->member->form_hash}';
ipb.vars['session_id'] = '{$this->member->session_id}';
</if>

Report feedback for any issues you may have.

Caching members is not a good idea, We can have more problems than before.

In my opinion, IPB should make an effort in 4.0 to have a solution for guests caching.

remove_guest_session.xml

Link to comment
Share on other sites

  • 7 months later...

hey guys, this topic is about half of the year old.

Are there any recomendations to speed up the nginx machine? I mean by some software tricks. Just now we are preparing new server and would be nice to implement some solutions that whould rise our performance.

Machine is dedicated for gallery and forum, which generates nearly 95% of our traffic.

Link to comment
Share on other sites

  • 3 weeks later...

we had implemented this solution and speed for guests is amazing. something like 20 to 30 times faster than for regular users.

is it good to cache php pages in ram disk? would it be faster than on regular sas hdd? how much faster should it be - it seems we have 10gb of free ram.

is it possible to somehow cache data for logged in users?

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...