PHP7 is the new generation of the php engine which is dramatically faster than 5.6 and significantly reduces memory consumption. But is it ready for production? Our answer is yes! We started planning our migration in advance and were one of the first companies of our scale to deploy PHP7 to our 1000+ servers which run more then 2M lines of php code.
We hope this talk will inspire you to join us in «powered by php7» club.
15. Pinba!
✦ Php is not a bottleneck anymore
✦ RT performance monitoring tool
✦ Extension for php + plugin for mysql
✦ Open source! http://pinba.org/
16. Request time
✦ Some API call: GET_USER
✦ avg request time = 0.12 sec
✦ request time = cpu time + i/o time
✦ i/o time = mysql + services + FS i/o +…
21. PHP7 alternatives?
✦ HHVM (Facebook, http://hhvm.com/)
✦ kPHP (VK.com, https://github.com/vk-com/kphp-kdb)
+ JIT, PHP5 compatible
— C++, extensions API
+ faster then HHVM
— no OOP support at all
36. Soft mocks!
✦ Soft means no extension
✦ Plain PHP, compatible with all PHP
✦ Replaces Runkit for us
✦ Open source!
(https://github.com/badoo/soft-mocks)
37. How it works:
✦ Rewrites code on the fly
✦ Inserts "interceptors" in methods
✦ Wraps all constant usages
✦ Uses PHP-Parser
39. 1 class A
2 {
3 public function getValue()
4 {
5 return 10;
6 }
7 }
1 class A
2 {
3 public function getValue()
4 {
if (SoftMocks::isMocked(A::class, __FUNCTION__)) {
return SoftMocks::getResult(…);
}
5 return 10;
6 }
7 }
Original
After SoftMocks::rewrite()
40. So…
✦ No extension dependency
✦ 1.5 weeks for development
✦ A bit longer to adapt tests
✦ More stable tests in general