Memcached php sessions keep increasing - php

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.

Related

Upgrade from PHP5 to PHP7 causes long TTFB

The issue
I recently upgraded PHP on my server from PHP 5.6 to PHP 7.0, for some reason this has caused an incredibly long TTFB (compared to before).
Quick overview of how I set up my website
My website uses a combination of client and server side optimizations to make my run at an insane speed (average of 250ms for an initial full page load), causing as little overhead for the users as possible.
However, ever since I upgraded to PHP 7.0, the time to first byte increased from around 50ms up to anywhere from 700ms to 2000ms (which feels like an eternity compared to the load times before this).
The question
I was wondering if there are known performance issues with PHP 7.0 compared to PHP 5.6, and if so how I could fix them. Thank you for your time

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.

FuelPHP site using 10x more memory on remote server

I'm building a website using the FuelPHP framework, which by default prints the execution time and memory usage at the bottom of the page. Now I just noticed that on my local machine, I have a pretty small memory footprint:
Page rendered in 0.0304s using 0.721mb of memory.
I deployed exactly this site (including a snapshot of the database) to my remote test server and suddenly memory usage increases by a factor of 10:
Page rendered in 0.0963s using 7.099mb of memory.
I cannot explain such a big difference from the details of execution alone, so I think the deviation must be in the environment.
Unfortunately I'm mainly a programmer, not really a server admin, so I don't really know where to start looking. So I'm going to ask a bit of a general question, which will hopefully give me some useful pointers: where should I start looking? The code is exactly the same and as far as I am aware both machines (local laptop and remote server) are fairly standard Apache installations with PHP5. Any answers suggesting specific Apache or PHP settings that might cause this, or specific lines to search for in the logs, are welcome.
I realise this is a pretty general question that might get me some downvotes, any constructive critisism is welcomed instead. Basically, I'm at a loss where to even start looking, at the moment.
Update: I decided to first exclude the framework as the culprit, so I ran the following one-line script on both machines:
Locally I get a value of about 115, while the remote server reports about 600.
Update 2: Just noticed I'm running PHP5.5 locally but server is only at 5.3. Maybe some bug that got fixed later - will upgrade that first.
Thanks for the suggestions guys, I fixed the problem.
As noted in the update to the original post, I realised I was running PHP5.5 locally but server was only at 5.3. After some ppa-magic with apt and some help from other questions on SO I managed to install Apache 2.4 with PHP 5.5.x. Now I actually see
Page rendered in 0.0261s using 0.582mb of memory.
locally and remotely
Page rendered in 2.3184s using 1.238mb of memory.
Assuming that a factor 2 is caused by the server being 64-bit and not my development machine, I can live with the remaining difference.
Use Xdebug to find out what functions are using all your memory.
Most likely it's a bug or design flaw in the framework.
It can be difficult or even impossible to get Xdebug working depending on your server. But sometimes it's pre-installed and simple.

Are Memcache and APC good together?

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.

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