Are Memcache and APC good together? - php

I have installed PHP5 - PHP5-MEMCACHE - PHP-APC.
Can they work like that together? Will the loading be fast with these modules ?
I tried to use them, I don't "see" particular differences, maybe the CPU is used less with these modules. My website doesn't have high traffic, but If i can save resources is better!
Thank you

APC keeps cache of PHP bytecode. Memcache keeps cache of your vars, that you set.
So answer is Yes, they can. They're made for different things.

They work together very well, you just need to use them properly :
Memcached is a distributed cache system. What that means in a nutshell is that if you have a cluster of servers all of them can access the same cache pool
APC is an opcache and local cache system. Meaning it optimizes the php scripts so when going through the compiler less operations are made and the code is executed way faster. Another use of APC is local cache, which means you can store values in the cache and access them from the machine running the code.

Yes, they can work together. Whether they will on a production system is another story...
Personally, I had to give up trying to get the following to work for any extended period of time:
Ubuntu 10.04
NGINX 0.7.65
PHP 5.3.2
php-apc
php5-memcache
It will run for awhile, but after stress testing php errors out. I can restart php-fastcgi via /etc/init.d/php-fastcgi and things will role along for some time more, but it always crashes again sooner than later.
I can run either/or without issue, but the two together won't cooperate for me. FYI I tried using binaries (apt-get packages), installing as PECL extensions, downloading source, but all roads lead me to the same sad fate. I also tried running the memache daemon local & remotely on my web host, but same outcome.

I'm working on mmo game based on JavaScript and PHP. We are using both of them. I can't tell you more, beacause I am only frontend developer, however I think if APC and memcache were bad we were not using it.

Related

Switching from APC to APCu

I am running a web server with Debian and I'm hosting a ZF1 project.
The PHP process crashes from time to time without any reason, so my hosting provider suggests that I should switch from APC to APCu caching. I'm not very familiar with PHP caching and I can't really find any documentation on the topic, but I read a few similar questions here.
As far as I understand the APCu caches only user data (whatever that means) and it's not the full features of the APC. Considering this, my question is will APCu increase the load of the server and will the PHP extension work out of the box without touching the ZF1 code?
http://zend-framework-community.634137.n4.nabble.com/Does-ZF-1-12-support-PHP-5-5-td4661902.html
You should upgrade to the latest PHP on a test environment, if it works well (most likely scenario), you can switch. PHP 5.5 has built-in opcode cache (http://php.net/manual/en/intro.opcache.php), so you won't lose performance. Very little difference can be between the performance of APCu and APC.
Also, function names are not identical (apcu_fetch for instance), so you have to modify the code to reflect this.

Memcached php sessions keep increasing

I run a lamp stack of a couple of application servers which used a single dedicated memcache server for hosting sessions. The problem is that the items in the cache increase in a steady almost linear pace. This worries me. I figured that when the cache fills out the oldest entries will be overwritten and there shouldn't be a problem. But it seems impossible to gain any insight in the actual usage.
The versions I use are as following:
server-side:
Ubuntu 10.04
memcached 1.4.2
application-side:
ubuntu 10.04
php 5.3.2
libmemcached-0.44
pecl memcached 1.0.2
I've also tried this setup with pecl memcached 2.0.0b1, pecl memcache 2.2.6 and build against libmemcached-0.49 of which only the last had a minor impact at all. Is this behavior normal and as intended or would this be a failure of session_destroy?
Regrettably it was my own misunderstanding of memcached which gave me a wrong impression about the behavior. After some additional research I came across two (1, 2) articles which clarified the internal workings for me.
Garbage will not be collected. This still doesn't give me insight in the actual usage but at least takes away some worries. As long as I don't get evictions it should be just fine.

How can I avoid 'make install' when building PHP in Unix environment?

I'm attempting to rapidly deploy a PHP application under apache2/PHP on a Unix host. The sysadmin hasn't heard of PHP so I'm looking to build/install myself. Unfortunately root access is two weeks of bureaucracy away so I'm looking for a way to use PHP and its requisite libxml2 without installing.
You can be a non-privileged user and build Apache and PHP. You can have your own prefix paths for the installs, and if the development headers for the necessary libraries are available you can use them. You're going to hit issues in that as not-root you'll have to start Apache on a port > 1024. You're also not going to have the system package management available, so updates will have to be likewise built. In short, it's doable, but depending on which UNIX you're actually using, may not be horrendously pleasant. PHP in particular needs many many libraries (and if you're building from source, runtime isn't enough, you need the dev headers files) to have a usable system.
Good luck.
You can't avoid make install, but you can maybe use --prefix

what is the easiest way for opcode caching with PHP/Apache?

I was thinking to use opcode caching for performance profit
what is the easiest way for opcode caching with PHP/Apache ?
and what are the performance improvements ?
I have read about xDebug but I was wondering if there are more options ?
I use the APC extension as an opcode cache on both my personnal server, and on the servers we are using at work -- and I've almost never run into any kind of trouble with it.
Installation is pretty easy : depending on your Linux distribution, you might want to use something like :
sudo aptitude install php5-apc
But you'd not necessarily have the last stable version... And I generally prefer using :
sudo pecl install apc
Which will fetch the last version from PECL and compile it (Note : you'll probably need to installed a package called php5-dev).
You'll then have to configure it ; see Runtime Configuration for the directives you can configure.
The performance improvements can vary depending on your server/application, but, on a server that only serves PHP pages (i.e. if your DB is on another machine) you might see a drop in CPU load that's quite important (I've seen CPU load go from 80% to 40-50% on a server, once)
Xdebug is not related to opcode caching nor performance : as its name indicates, it's useful for debugging.
And Xdebug should not be installed on a production server : it can be a pain, when it comes to performances -- I suppose it's because it "hooks" into PHP and add lots of stuff, like logging many informations useful for debugging ; which means more calculations to do -- which takes time and CPU.
Try APC : been using it with Mediawiki and the results are significant.
Other popular options are eAccelerator and APC.
Performance improvements will depend on the web app you're caching. Here are some benchmarks for the Drupal CMS using APC and eAccelerator, and here's the same site's tutorial on installing APC (nice and easy).
On Debian/Ubuntu, try:
sudo aptitude install php5-xcache
A commercial solution is from Zend, http://www.zend.com

Configuring APC with Drupal

I am working on a website which is hosted on a VPS with CENTOS 5.4 i686 virtuozzo installed. I have a drupal installation on the server which gets around 100s of authenticated users at the same time.But at a certain point of time the server stopped responding and the site went offline. So, I tried installing the opcode cache - Alternative PHP Cache.
While the rest parts of the server work fine, the Drupal installation crashes as soon as I install PECL APC with the following message
Fatal error:Cannot run code from this file in conjunction with non encoded files in /home/apogee/public_html/2010/themes/zen/zen/block.tpl.php.
Could you please tell me a way to properly configure Drupal to use APC ?
Thanks
niting
I think the error comes from Zend Encoder...if you don't need it installed then uninstall it and see if that fixes things. If you do need it (closed-source module?), then not sure if that and APC can play nicely together...
you must be disable APC on php.ini
apc.enabled=0
APC and Zend Optimizer can't work with together
David Strauss at four kitchens has done some work on getting Pressflow (Performance tuned Drupal distribution) to work well with APC https://wiki.fourkitchens.com/display/PF/Tuning+APC.
With that much concurrent usage it may be worth your while to look into pressflow.
I have a couple of websites using APC and I've never seen that kind of error -- even with the Drupal-based ones.
After a bit of searching, it seems related to Zend Optimizer and/or Encoder (see the last answer on this thread, for instance), and not to Drupal itself.
I suppose you should use either Zend products, or APC, but not a combinaison of both.

Categories