Results 1 to 21 of 21
  1. #1
    Join Date
    Jul 2008
    Posts
    273

    The Best Cache Solution

    Hello again everybody, I'm developing a script and I'm having doubts about what kind of cache to use parts of the code.

    What would have higher performance and consume less server, the system will be aimed at high-traffic, about 4000 users browsing simultaneously.

    smarty cache or memcached+memcache

    What would be best solution ?

  2. #2
    Join Date
    May 2009
    Location
    SLASH ROOT
    Posts
    867
    Memcache is not an opcode cache system, it is based on distributed memory caching. I presume you are referring to PHP code and my personal recommendation will be APC with PHP as DSO module.

    Also make sure that webserver/PHP and APC are tuned for handling such a high traffic.
    █ WebHostRepo.com
    █ Linux | Windows
    | VPS | Cloud
    █ Outsourced Technical Support since 2009
    █ sales@webhostrepo.com

  3. #3
    Join Date
    Jul 2008
    Posts
    273
    Cache server is not what I want to cache and certain parts of the site, certain mysql query.

    I want the best possible solution, which consumes fewer resources and is fast.

  4. #4
    Join Date
    May 2009
    Location
    SLASH ROOT
    Posts
    867
    As I mentioned earlier APC is non-distributed while memcache is distributed cache system. If you have multiple webservers for your website (load balanced), you need a distributed cache system (memcache).

    If you have just 1 webserver go for APC as this is ~4 times faster than memcahe.
    █ WebHostRepo.com
    █ Linux | Windows
    | VPS | Cloud
    █ Outsourced Technical Support since 2009
    █ sales@webhostrepo.com

  5. #5
    Join Date
    Aug 2012
    Location
    Phoenix
    Posts
    15
    With 4k concurrent users, I would stray away from any file caching strategies where the cache resides as a file on the disk. Disk I/O will become a problem as you grow and if you service your users from multiple application servers, you would have to move to a storage server so your application servers all have access to the cache, which is pretty slow for cache retrieval - and your pipes will be limited.

    Given your current load and if you expect it to grow, you will probably have to scale out to multiple application servers, which you would need memcache for anyway.

  6. #6
    Join Date
    Jul 2008
    Posts
    273
    Quote Originally Posted by jeremyw View Post
    With 4k concurrent users, I would stray away from any file caching strategies where the cache resides as a file on the disk. Disk I/O will become a problem as you grow and if you service your users from multiple application servers, you would have to move to a storage server so your application servers all have access to the cache, which is pretty slow for cache retrieval - and your pipes will be limited.

    Given your current load and if you expect it to grow, you will probably have to scale out to multiple application servers, which you would need memcache for anyway.
    So it would be better than smarty cache memcache? have some other solution?
    I also thought about full cache with nginx, but it would be written to what would become slow?

  7. #7
    Join Date
    Aug 2012
    Location
    Phoenix
    Posts
    15
    Yeah, if you wanted to implement a smarty caching strategy that utilizes memcache through their API, that would be a good result. Just stay away from the default file caching strategy.

    I personally do not have experience with nginx, so I cannot say what the caveats are regarding it.

    Personally, I use Apache, PHP, MySQL and Memcache to service 15,000 concurrent users in my environment having 10 application servers, each with a memcache instance and it performs wonderfully. Have plenty of headroom and I cache everything from database result sets to serialized PHP classes and objects from my DAL to compiled html segments.

  8. #8
    Join Date
    Jul 2008
    Posts
    273
    Quote Originally Posted by jeremyw View Post
    Yeah, if you wanted to implement a smarty caching strategy that utilizes memcache through their API, that would be a good result. Just stay away from the default file caching strategy.

    I personally do not have experience with nginx, so I cannot say what the caveats are regarding it.

    Personally, I use Apache, PHP, MySQL and Memcache to service 15,000 concurrent users in my environment having 10 application servers, each with a memcache instance and it performs wonderfully. Have plenty of headroom and I cache everything from database result sets to serialized PHP classes and objects from my DAL to compiled html segments.
    memocache you use only for mysql correct?
    which technology to use to cache the php page?

  9. #9
    Join Date
    Aug 2012
    Location
    Phoenix
    Posts
    15
    No, I do not use the memcache plugin for mysql. I use it strictly in the PHP layer and do my own caching of mysql result sets, objects and etc.

    I use my own technology. Code everything myself. Memcache is a native PHP extension, so adding a memcache layer into your PHP application is pretty easy.

  10. #10
    Join Date
    Jul 2008
    Posts
    273
    Quote Originally Posted by jeremyw View Post
    No, I do not use the memcache plugin for mysql. I use it strictly in the PHP layer and do my own caching of mysql result sets, objects and etc.

    I use my own technology. Code everything myself. Memcache is a native PHP extension, so adding a memcache layer into your PHP application is pretty easy.
    I understand, but I say this only you use memcache to cache mysql or also cache web content.

  11. #11
    Join Date
    Aug 2012
    Location
    Phoenix
    Posts
    15
    I use memcache for both scenarios. I also use memcache for other types of data as well.

  12. #12
    The quick and dirty: use smarty cache plugins to cache IN memcache.

    Smarty can cache at several levels (cache php, cache evaluated php, etc), and you should cache the final html where possible.

    If you must, cache your mysql arrays, but if they're heavily dynamic, you need to be more selective. There isn't a magic bullet, you should start at the most used queries that change the least (top 5 items on your store, front page, etc).

  13. #13
    A big music distribution site I worked for used memcache for the MVC web app.

  14. #14
    Join Date
    Aug 2012
    Location
    Houston, TX
    Posts
    65
    In my experience, the file cache is the fastest. I should clarify that I haven't done any serious performance tests, but in all the time I've used Smarty, I have found the file cache to work best.

  15. #15
    Join Date
    Aug 2012
    Location
    Phoenix
    Posts
    15
    Quote Originally Posted by RyStark View Post
    In my experience, the file cache is the fastest. I should clarify that I haven't done any serious performance tests, but in all the time I've used Smarty, I have found the file cache to work best.
    Using Disk I/O for caching is very slow. It just doesn't scale. If your using Disk I/O for caching, its only suitable for low traffic.

  16. #16
    Join Date
    Jul 2007
    Location
    Virginia
    Posts
    1,314
    Use an in-memory key-value store. You will suffer from I/O issues if you choose to go with a disk-based cache.
    ~ @PreetamJinka

  17. #17
    Join Date
    Aug 2012
    Location
    Houston, TX
    Posts
    65
    Quote Originally Posted by jeremyw View Post
    Using Disk I/O for caching is very slow. It just doesn't scale. If your using Disk I/O for caching, its only suitable for low traffic.
    You're right, I should had clarify that is also not a stable solution for high traffic sites. File caching is best when you have a single server instance or using shared drive in a server cluster, but when you have a web server cluster (two or more web servers serving the same content), the problem with file based caching is not sync across the web servers. To perform a simple rsync on the caching directories is error prone. In the end, memcache might be a better solution.
    RyStark - Superb Hosting Solutions
    Shared Hosting | Dedicated Servers

  18. #18
    Memcached is the only real option here.

  19. #19
    most time cache performance is trade off by dynamic content visiting . if you site get much more query request than updating request then there is an solution for more high performance called cache forecast .

  20. #20
    How reliable is Memcached? I thought I remember it having reliability problems at some point in the past.

  21. #21
    Join Date
    Nov 2009
    Location
    Riga, Latvia
    Posts
    473
    Consider using nginx as a proxy webserver instead.
    SERVERIA.COM: top secret servers Fully managed confidential dedicated Linux & Windows servers.
    SERVERADE.NET: server management PROs Request a quote for your server now!
    SECRETGSM.COM: anonymous SIM cards Anonymous prepaid calling cards & more.

Similar Threads

  1. Replies: 0
    Last Post: 04-08-2012, 10:31 PM
  2. Best Cache Solution?
    By investorz in forum Web Hosting
    Replies: 20
    Last Post: 02-22-2012, 01:41 PM
  3. 7,200RPM with 32MB Cache or 10,000RPM with 16MB Cache
    By xmutan in forum Dedicated Server
    Replies: 20
    Last Post: 08-13-2009, 05:43 PM
  4. mod_cache does not cache the homepage but the rest is cached. Any solution?
    By EnAlgures in forum Hosting Security and Technology
    Replies: 0
    Last Post: 03-23-2009, 03:03 PM
  5. Replies: 3
    Last Post: 03-28-2005, 05:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •