0

I have high-load informative website with 10 000+ hits/day. It was rewritten on Symfony 2 Framework with Doctrine2 ORM. Site have heavy informative pages, each load on development server 0.5 - 1.5 seconds approximately. Note, that it time on development server, so it has minimal load.

I know there are many cache providers such as Varnish, Memcached, APC, HTTP, etc... Please, suggest me on what layer (DB, HTTP, etc...) and what type of cache better to use for improve performance of this site?

Victor Bocharsky
  • 11,930
  • 13
  • 58
  • 91
  • All depends in what you want to cache, and how frequently you'll need to refresh the cache, and thousands of other factors.... there is no best answer to such an open-ended question – Mark Baker Nov 10 '14 at 08:30
  • @MarkBaker I know that the load on the database is minimal. I have heavy pages with lot of info, and it heavily rendering. My goal is to use some cache that allows the site to withstand a load. But I don't know what cache to choose – Victor Bocharsky Nov 10 '14 at 08:38
  • So start by asking yourself "what do you want to cache?" – Mark Baker Nov 10 '14 at 08:38
  • @MarkBaker I think I need to cache whole static page, that already rendered once, and then show to all users this cached page until it will be outdated – Victor Bocharsky Nov 10 '14 at 08:41
  • 1
    @Victor The first thing you would do is benchmarking. The symfony toolbar helps you a bit with it, there are many ways to properly find out where the time is actually lost. You don't really know it apparently. Then you can decide what you really want to cache. it is hard to suggest caching if you don't know where the problem is. – Koalabaerchen Nov 10 '14 at 09:21
  • @Koalabaerchen, Thanks, I try to benchmarking my app with symfony toolbar first – Victor Bocharsky Nov 10 '14 at 09:28
  • 1
    @Victor : For HTTP Caching, you should take a look at [FOSHttpCacheBundle](https://github.com/FriendsOfSymfony/FOSHttpCacheBundle/) – Brice Nov 10 '14 at 13:32
  • 10k hits a day sounds like a lot but it's 0.116 requests per second. – ceejayoz Nov 11 '14 at 04:06

1 Answers1

2

Like @Mark said in the comment, "there is no best answer to such an open-ended question". At first, let's find the what: which component is the system bottleneck, DB, HTTP response, javascript...?

And in each component, there are other questions:

  • DB: Which queries slow the system down (Hint: using Log Slow Query)? Can we refator those? (This is often the key factor, given that it's informative website) What is the result of MySQL Explain or other alternatives?
  • HTTP response: Does it take unreasonably much time to transport rendered content to client machine? (Hint: using Web Developer Tools or even cUrl). Does it load the static files over and over again without utilizing the HTTP cache? Does using Nginx caching help?
  • Javascript: Are there any scripts that block browser from rendering the page? Are there any errors caused by conflicts of scripts (which will add up the waiting time for sure)?

....

Let's have the checklist, which list those questions <--> answers. The answer for "what type of cache better to use for improve performance of this site" TOTALLY DEPENDS on those.

Somewhere to reference:

And I recommend a very very good book: Scale PHP Application, in which you can learn real use cases, how to debug, how to profile..

TuanNguyen
  • 996
  • 9
  • 9