T4g (AWS Graviton 2 burstable EC2) instance PHP performance
After my early post with performance measurement, I have found an issue with PHP performance on the Graviton 2 processor (C6g, M6g) processor. The issue was recognized and AWS team contributed to the PHP many performance fixes for ARM 64 infrastructure.
Original old post:
AWS worked together with the PHP community to drive major improvements to the performance of the PHP software stack on the ARM Graviton2-based instances. By using AWS Graviton2 based instances, the latest release of PHP-7.4.9 currently experiences up to 37% faster execution time compared to the previous release PHP-7.3. This significantly lowers the cost of running terrible PHP software such as Magento 2 on Amazon EC2 M6g instances.
AWS launched T4g instances, a new generation of low-cost burstable instance type powered by AWS Graviton2, a processor custom-built by AWS using 64-bit Arm Neoverse cores. Using T4g instances you can enjoy a performance benefit of up to 40% at a 20% lower cost in comparison to T3 instances, providing the best price/performance for a broader spectrum of workloads.
In our previous test with PHP showed the next results:
A1.large PHP performance (ARM GRAVITON 1 AWS)
The code took 0.38810396194458 seconds to complete.
The code took 0.38808822631836 seconds to complete.
The code took 0.38812589645386 seconds to complete.
The code took 0.38790202140808 seconds to complete.
The code took 0.38788604736328 seconds to complete.
The code took 0.38789796829224 seconds to complete.
The code took 0.387943983078 seconds to complete.
The code took 0.38829302787781 seconds to complete.
The code took 0.38884282112122 seconds to complete.
The code took 0.38802289962769 seconds to complete.
C6g.large PHP performance (ARM GRAVITON 2 AWS)
The code took 0.26189398765564 seconds to complete.
The code took 0.25753402709961 seconds to complete.
The code took 0.26207208633423 seconds to complete.
The code took 0.25553894042969 seconds to complete.
The code took 0.26356601715088 seconds to complete.
The code took 0.25494980812073 seconds to complete.
The code took 0.25964903831482 seconds to complete.
The code took 0.26054716110229 seconds to complete.
The code took 0.27059602737427 seconds to complete.
The code took 0.25764012336731 seconds to complete.
The code took 0.2580840587616 seconds to complete.
The code took 0.26006889343262 seconds to complete.
Let's check what new version of the PHP 7.4.9+ can achieve with burstable Graviton 2 processor.
How to install PHP-7.4 on EC2 AWS Linux 2 including ARM graviton
Installation instructions: https://github.com/Genaker/Magento-AWS-Linux-2-Instalation/blob/master/install-php.sh
sudo amazon-linux-extras enable php7.4sudo amazon-linux-extras install php7.4
By the way, it is a special Open-Source project how to setup Magento 2 infrastructure without any dummy Dockers:
https://github.com/Genaker/Magento-AWS-Linux-2-Instalation
I like to use Amazon Linux Extras — Extras is a mechanism in Amazon Linux 2 to enable the consumption of new versions of application software on a stable operating system . Extras help alleviate the compromise between the stability of the OS and freshness of available software.
AWS contributions to PHP-7.4
FunctionSpeedupCommits to PHP-7.4inc/dec1.5xhttps://github.com/php/php-src/pull/4094add/sub1.82xhttps://github.com/php/php-src/pull/4095hash_init1.61xhttps://github.com/php/php-src/pull/4096hash_vect1.72xhttps://github.com/php/php-src/pull/4126crc3229xhttps://github.com/php/php-src/pull/4108rev647.8xhttps://github.com/php/php-src/pull/4109base64 encode3.5xhttps://github.com/php/php-src/pull/4381base64 decode2.15xhttps://github.com/php/php-src/pull/4381string addslashes2.8xhttps://github.com/php/php-src/pull/4396string stripslashes4.9xhttps://github.com/php/php-src/pull/4396
Future developments
PHP-8 plans to release in 2021 with more improvements for Arm64: an improved toupper/tolower function brings performance up by 16.5x. https://github.com/php/php-src/pull/4439
AWS has contributed changes to PCRE2 release 10.34. PCRE2 version 10.34 is used in PHP-8 to match regular expressions. PCRE2 accounted for about 8% of execution time in WordPress benchmark. The change contributed by AWS to PCRE2 vectorizes first character match and matching pairs of characters with NEON instructions: performance improves by up to 8x on M6g. https://lists.exim.org/lurker/message/20191106.052444.1ea1a176.en.html
PHP-8 plans to feature a new JIT compiler that optimizes the PHP byte-code in the Opcache. The JIT is currently developed on x86 and is based on Lua’s JIT. As Lua’s JIT supports ARM64, we work with PHP developers to enable and to tune the Opcache JIT in PHP-8 to get the best performance on AWS Graviton processors.
I would like to suggest the Amazon team also to contribute to the Magento 2 project because things are going absolutely crazy and stupid over there. Magento 2 Performance is sucks…
Ok, what result we are having :
T4G.Small PHP 7.4.9 performance (ARM GRAVITON 2 AWS)
The code took 0.15448880195618 seconds to complete.
The code took 0.15383291244507 seconds to complete.
The code took 0.15404081344604 seconds to complete.
The code took 0.15255999565125 seconds to complete.
The code took 0.15363001823425 seconds to complete.
The code took 0.15481495857239 seconds to complete.
The code took 0.15435600280762 seconds to complete.
The code took 0.15445303916931 seconds to complete.
The code took 0.15466809272766 seconds to complete.
The code took 0.15391087532043 seconds to complete.
The code took 0.15402483940125 seconds to complete.
The code took 0.15403985977173 seconds to complete.
The code took 0.15382289886475 seconds to complete.
The code took 0.15494513511658 seconds to complete.
The code took 0.15454292297363 seconds to complete.
The code took 0.15420317649841 seconds to complete.
The code took 0.15310406684875 seconds to complete.
The code took 0.15427589416504 seconds to complete.
The code took 0.15364098548889 seconds to complete.
The code took 0.15369701385498 seconds to complete.
The code took 0.15444684028625 seconds to complete.
The code took 0.15394687652588 seconds to complete.
it is a great result for inexpensive T3 instance type becue the fastest and expansive C5.large instance has the next results:
C5.large PHP performance
The code took 0.10848188400269 seconds to complete.
The code took 0.10874104499817 seconds to complete.
The code took 0.10939693450928 seconds to complete.
The code took 0.10821604728699 seconds to complete.
The code took 0.10948896408081 seconds to complete.
The code took 0.10880613327026 seconds to complete.
It is still slower than x86 Intell Xeon however not so big a deal, any way it is better than the awful Magento Commerce Cloud, and the cost of these instances approximately 7$ months not a couple thousand in the case of Magento Cloud. Basically I didn’t fid price yet (just today t4g has been released September/14/2020), the estimate was made based on T3 instances price. I will update price information soon
T3.micro PHP 7.3 performance
The code took 0.19494104385376 seconds to complete.
The code took 0.12496709823608 seconds to complete.
The code took 0.15236806869507 seconds to complete.
The code took 0.11733198165894 seconds to complete.
The code took 0.11597108840942 seconds to complete.
The code took 0.15004992485046 seconds to complete.
The code took 0.11619806289673 seconds to complete.
The code took 0.11625099182129 seconds to complete
The code took 0.12474203109741 seconds to complete.
The code took 0.13158011436462 seconds to complete.
T3.small PHP 7.4.9 performance
The code took 0.12185716629028 seconds to complete.
The code took 0.14572787284851 seconds to complete.
The code took 0.23651504516602 seconds to complete.
The code took 0.10497307777405 seconds to complete.
The code took 0.10684490203857 seconds to complete.
The code took 0.10897707939148 seconds to complete.
The code took 0.12284398078918 seconds to complete.
The code took 0.11216402053833 seconds to complete.
The code took 0.12797403335571 seconds to complete.
The code took 0.12367010116577 seconds to complete.
The code took 0.11420488357544 seconds to complete.
The code took 0.10658693313599 seconds to complete.
The code took 0.26668691635132 seconds to complete.
We can see that performance is approximately the same however T4 has only 1 physical CPU when graviton has 2 Physical CPU. Read my older original post to know why it is impotent.
PHP 7.4 vs 7.3 ARM performance:
PHP 7.4 vs C5 vs A1 vs T3, T4g performance:
PHP release 7.4.9 is key to obtain maximum performance from the Graviton2-based T4g, M6g, C6g, and R6g instances. PHP 7.4.9 makes the AWS Graviton2 based instances even more appealing by delivering both higher performance and lower cost Magento hosting compared to the Magento Cloud.
Updated price T4g price
The smallest one Nano = 3$ per month vs T3 3.73$
the normal one Small = 12$ per months vs T3 14.97$
Basically price is not much cheaper. Approximately 20% cheaper
The biggest one is 2xlage = 193.5