Degraded performance on a production machine - php

On my development machine my application used up about 4-6MB of memory per request. After switching to a production machine those numbers went as high as 21+MB per request, without any speed improvement (0.30 - 1.2 seconds, which I really hoped to improve on my production machine). Some portions of application (like database bootstrapping) used up 271KB on a development machine and 2.5MB on the production one, so I'm wondering what could be the reason for this. My application uses Zend Framework 1.10.8 (MVC) and Doctrine 2.0beta4 ORM and PDO_MySQL as a database adapter.
My development machine:
Windows 7 32bit, 1.8GHz Dual Core, 2GB RAM, PHP 5.3.2, Apache 2.2.15, MySQLnd 5.0.7-dev (Zend Server CE)
My production machine:
CentOS 5.5 64bit, 2.66GHz Quad Core, 8GB RAM, PHP 5.3.3, Apache 2.2.16, MySQL 5.1.48
Also, I wasn't really able to find a bottleneck, it's like it's application-wide. Please tell me if I should provide any additional info.
Update:
Zend Server, which I use on my dev machine, has Zend Optimizer+ and APC enabled, and my sysadmin recommended me that I should use eAccelerator, so I followed his advice. However, on phpinfo() I see this:
eAccelerator 0.9.6.1
Caching Enabled true
Optimizer Enabled true
Check mtime Enabled true
Memory Size 16,777,144 Bytes
Memory Available 16,772,976 Bytes
Memory Allocated 4,168 Bytes
Cached Scripts 0
Removed Scripts 0
Does that mean it's not properly configured?

Windows 7 32bit,
CentOS 5.5 64bit,

Related

PHP high CPU usage - how to detect and best settings

How can I troubleshoot high CPU usage caused by PHP-FPM on a production server running PHP 8.1 on Ubuntu 22.04 when the same issue is not present on a development server with identical PHP settings? I setup correct values for pm_start_servers etc (https://thisinterestsme.com/php-fpm-settings/ following this)
4 cores, WordPress site with woo-commerce, and 8 GB ram. Ram usage around 30%)

PHP Laravel memory usage increase on Direct Admin server

We have developed Laravel based software, locally tested with Laravel Valet and everything is working fine. One installing on a staging (direct admin) webserver with exactly the same database and code the memory usage dramatically increased.
Local testing specs:
OS: MacOS Catalina
Proc: 2.3 GHz 8-Core Intel Core i9
Memory: 16 GB 2667 MHz DDR4
Staging server specs:
OS: CentOS 7.0 64-Bit
Processor Speed (MHz) 2693.670
Total Memory 1014728 kB
This is a basic static page:
Staging server: 21MB, PHP 7.4.2
Development machine: 5MB, PHP 7.4.4
Another larger page (which needs optimization):
Staging server: 101MB, PHP 7.4.2
Development machine: 85MB, PHP 7.4.4
We know this development machine is a lot slower but we cannot explain the memory usage increase. Does anybody know how to analyze and resolve this?
The used framework is Laravel v6.18.20
Well Laravel Valet uses a very lightweight web server and that is a huge difference, I suggest to configure your webserver to use Nginx instead of Apache and be sure you are using PHP as FPM module, generally speaking, servers with Direct Admin uses Apache webserver by default and that will increase the memory usage of every request.
Try to switch to an Nginx webserver

Memcache PHP extension on windows 10 works intermittently

I have memcache extensions on apache/php windows 10 (details at the end)
Created a simple test:
$memcache = new Memcache;
$memcache->addServer("ext-memcached.e-memcached.xxx.net",11211);
$memcache->addServer("ext-memcached.e-memcached2.xxx.net",11211);
$memcache->addServer("ext-memcached.e-memcached3.xxx.net",11211);
$key='xxx_54921';
$settings = $memcache->get($key);
print_r ($settings);
the memcache servers are on AWS and they work well (production servers).
This test code works - it retreives the value from the memcache servers.
However if I wait a couple minutes and refresh it will not return value.
Then if I refresh again it will return the value.
The same code/config works from another dev computer.
What can cause this?
Config:
PHP Version 5.6.34
Windows NT SPECTRE 6.2 build 9200 (Windows 8 Home Premium Edition) i586
Build Date Feb 28 2018 17:45:55
Compiler MSVC11 (Visual C++ 2012)
Architecture x86
Memcache extension:
ts x86 version from here:
https://windows.php.net/downloads/pecl/releases/memcache/3.0.8/
memcache info:
memcache support enabled
Version 3.0.8
Revision $Revision: 329835 $
Directive Local Value Master Value
memcache.allow_failover 1 1
memcache.chunk_size 32768 32768
memcache.compress_threshold 20000 20000
memcache.default_port 11211 11211
memcache.hash_function crc32 crc32
memcache.hash_strategy standard standard
memcache.lock_timeout 600 600
memcache.max_failover_attempts 20 20
memcache.protocol ascii ascii
memcache.redundancy 1 1
memcache.session_redundancy 2 2
The memcached service doesn't actually install the PHP memcached extension for you. It only installs the memcached server used to store your cache.
You'll need to download the Windows DLL from the PECL repository first (click on the blue Windows DLL link). Then you must add the extension=php_memcache.dll line to the correct php.ini file for your SAPI. Also, note the extension DLL file needs to be placed in the correct path for your XAMPP installation.
For Apache, simply create a script in your document root with the line
For the CLI SAPI, you can use php.exe --ini to do the same. Again, you may need to rely on the XAMPP package if it has modified your configuration path (since this is a compile time directive).
After making your changes to php.ini you will need to restart PHP for the changes to take effect.
You can refer: https://pureform.wordpress.com/2008/01/10/installing-memcache-on-windows-for-php/
Since you're using PHP 7 on Windows it's probably also important to note that the compiled DLL from PECL may not actually work under apache for Windows, because you're more than likely using a theaded SAPI. So make sure you are downloading the correct version. As far as I can tell that version is only compiled to work with up to PHP 5.6. The github alternative, for PHP 7, available at https://github.com/nono303/PHP7-memcahe-dll as mentioned in the comments is tested under non-thread safe. So you may only be able to get this working for your CLI scripts on Windows.
The problem seems to be more in the way you are writing (set) and getting (get) the data having multiple nodes. - Memcache does not support replication.
Try a single node, in that case, you should be available to get the data just after being set.
When having multiple nodes "sharding" is a common approach to store the data, this means that a logic is implemented in place to determine what server to use for either writing or getting the data:
From https://en.wikipedia.org/wiki/Memcached:
Clients use client-side libraries to contact the servers which, by default, expose their service at port 11211. Both TCP and UDP are supported. Each client knows all servers; the servers do not communicate with each other. If a client wishes to set or read the value corresponding to a certain key, the client's library first computes a hash of the key to determine which server to use. This gives a simple form of sharding and scalable shared-nothing architecture across the servers.
Therefore in PHP client you could try a consistent hashing:
$memcache = new Memcache;
$memcache->setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
From: http://www.php.net/manual/en/memcached.constants.php
Memcached::OPT_LIBKETAMA_COMPATIBLE
Enables or disables compatibility with libketama-like behavior. When enabled,
the item key hashing algorithm is set to MD5 and distribution is set
to be weighted consistent hashing distribution. This is useful because
other libketama-based clients (Python, Ruby, etc.) with the same server
configuration will be able to access the keys transparently.
Note:
It is highly recommended to enable this option if you want to use
consistent hashing, and it may be enabled by default in future releases.
Also, try:
memcache.hash_strategy = consistent;
Check this post for more details: https://blog.fedecarg.com/2008/12/24/memcached-consistent-hashing-mechanism/
and this answer: https://stackoverflow.com/a/48006009/1135424
Check your
memcache.redundancy memcache.redundancy
setting, your data is not be available on every memcached node. Setting it to 3 should be sufficient in your example case.

Why hhvm performance is terrible on small webapp?

Recently i made a performance scenarios with hhvm and i found hhvm faster than php-fpm5.5 (with opcache) only if the testing website quite big (200+ includes) but perform terrible with small footprint application like Yii 1.1.16 testdrive contact page.
did i make some mistake or it is normal?
environment:
Machine: 64 GB / 20 CPUs digitalocean
PHP 5.5.9-1ubuntu4.7 OPcache v7.0.3
HipHop VM 3.6.1 (rel)
Ubuntu 14.04.2 LTS (GNU/Linux 3.13.0-46-generic x86_64)
cpu consumption serving small footprint webpages on hhvm
HHVM can be slower for /very/ lightweight pages; however, there's not enough information here to be sure if that's the case here:
are you sending warmup requests? If so, how many, and how? The JIT will be slower for the first few requests on almost any workload (same applies to other JITs, such as the JVM)
how are you actually measuring? Siege, ab, ?

How to improve performance of my Joomla based Intranet system?

I have a Joomla 1.5.10 based Intranet system. In this application, we have more than 80% custom extensions. Below is the configuration:
Apache version : Apache/2.2.22 (Win32) mod_ssl/2.2.22 OpenSSL/0.9.8
PHP version : 5.3.13
MySQL version : mysqlnd 5.1.11
It has 3 dedicated Appliocation Server which configuration is :
Windows Server 2008 Standard Edition Service Pack 2
Compiler: MSVC9 (Visual C++ 2008)
Architecture: x86
Again, it has dedicated DB server which configuration is :
8x Intel(R) Xeon(R) CPU X5460 #3.16GHz, 8.0GB RAM, Windows Server 2008 Standard Edition Service Pack 2.
Below is the MySQL settings in my system:
Sl.# Parameter Value
1 Key Buffer 547M
2 Sort Buffer Size 256K
3 Query cache limit 4M
4 Cache size 350M
5 Long query time 5
6 Interactive timeout 300
7 Max Connection 800
8 Thread cache size 36
We have configured WAMPSERVER (32 BITS & PHP 5.3) 2.2E on our servers and then install MySQL5.1 on other dedicated server. Hence, we are not using MySQL provided with WAMP.
My system become too slow or crash when number of DB connection threads crossed 100. Number of logged-in users we can see are 3000-5000 only. Multiple queries start logging in the slow query logs and huge number of queries are in sleep state. Those queries which are running normal also start logging in slow query log and taking much time in execution.
I am unable to find the bottlenecks in my system. Is there Joomla or MySQL creating bottlenecks. Would upgrade helpful to avoid the bottlenecks and increased the performance of our system? If yes, what should we upgrade - Joomla or MySQL and what will be the strategy to upgrade the system. Is there a known performance/scalability issue in 1.5.10 that is resolved by an upgrade?
My overall goal is to increase the system performance.
Thanks in advance.
First of all as mentioned in my comments, upgrading your CMS to atleast Joomla 1.5.26 will help. You're running PHP 5.3 and only Joomla 1.5.15+ is fully compatible with this PHP version. Seeing as you're using 1.5.10, there will be some issues there.
Apache is not an issue here. There are sites out there running Joomla that have thousands of users and run Aache without any problems, so not to worry about this.
From Joomla 1.6 onwards, the optimization started. Reduced and sorted database tables, endless bug fixes and also security issues. The framework has also improved majorly not to mention it supports PDO, mysqli (more secure than mysql) and postgre. Ugrading to Joomla 3.2 (latest version) will be of course a massive step. You will have to make all your custom extensions compatible with the new Joomla version and keep up to date with the latest coding standards. Even though this is a big step and will of course take some time, it's fully worth it. Joomla 1.5 hasn't been supported for a long time now and things are moving forward majorly.
Your server specs are good, you're running a decent PHP and Apache version, you're MySQL version could be upgraded however it's still not bad. So overall, it's not a server related issue.
I do think that it could very well be the way your custom extensions have been coded. So my final suggest would simply be taking a backup of your site and start migrating it and all of your extensions to Joomla 3.2.
You can change the webserver. Apache is totally bloat. Lighttpd can help to fix the problem. It' also simpler to run. A cms upgrade most likely break something.

Categories