27

2 & PHP 7.0 - Magento · Switching a Magento site to PHP 7.1 • TEST, TEST, TEST. Then TEST again • If possible: install a new server, roll over to production –If you must replace

  • Upload
    others

  • View
    8

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 2 & PHP 7.0 - Magento · Switching a Magento site to PHP 7.1 • TEST, TEST, TEST. Then TEST again • If possible: install a new server, roll over to production –If you must replace
Page 2: 2 & PHP 7.0 - Magento · Switching a Magento site to PHP 7.1 • TEST, TEST, TEST. Then TEST again • If possible: install a new server, roll over to production –If you must replace

HTTP/2 & PHP 7.0:

New Infrastructure Technologies’

Impact on Magento Performance

Page 3: 2 & PHP 7.0 - Magento · Switching a Magento site to PHP 7.1 • TEST, TEST, TEST. Then TEST again • If possible: install a new server, roll over to production –If you must replace

Co-Founder & CTO, Shoppimon

@shevron

Shahar Evron

Page 4: 2 & PHP 7.0 - Magento · Switching a Magento site to PHP 7.1 • TEST, TEST, TEST. Then TEST again • If possible: install a new server, roll over to production –If you must replace

Intro:

Why Does Performance Matter?“Premature optimization is the root of all evil.”

-- Knuth (?)

Page 5: 2 & PHP 7.0 - Magento · Switching a Magento site to PHP 7.1 • TEST, TEST, TEST. Then TEST again • If possible: install a new server, roll over to production –If you must replace

Slow is the New Down

• Research shows that store performance directly impacts

a store’s bottom line:

– Example: A store making $15,000,000 / year, is losing approx.

$600,000 to slowdowns

• Speed impacts scalability and operational costs:

– Less time per request more requests per process / minute

– Less memory per process more processes per hardware

Page 6: 2 & PHP 7.0 - Magento · Switching a Magento site to PHP 7.1 • TEST, TEST, TEST. Then TEST again • If possible: install a new server, roll over to production –If you must replace

PHP 7.x“7 is perceived as a lucky number in both the Western world

and Chinese culture. A little bit of luck never hurt anybody.”

-- PHP RFC: Name of Next Release of PHP

Page 7: 2 & PHP 7.0 - Magento · Switching a Magento site to PHP 7.1 • TEST, TEST, TEST. Then TEST again • If possible: install a new server, roll over to production –If you must replace

What’s PHP 7?

• PHP 7 is the current major version of PHP

– PHP 5.6 support ends on Dec. 2017

• PHP 7 introduces substantial memory footprint

reduction and speed improvements

• There are also some cool new language features

Page 8: 2 & PHP 7.0 - Magento · Switching a Magento site to PHP 7.1 • TEST, TEST, TEST. Then TEST again • If possible: install a new server, roll over to production –If you must replace

PHP 7.x Magento Support

• Support for Magento 1.x: Unofficial but “known to work”

– Many 3rd party extensions may not work

– There are extensions that can help with compatibility

• Support for Magento 2.x: Official for 7.0

– 7.1 not officially supported just yet, but it probably works™

Page 9: 2 & PHP 7.0 - Magento · Switching a Magento site to PHP 7.1 • TEST, TEST, TEST. Then TEST again • If possible: install a new server, roll over to production –If you must replace

PHP Version Adoption

Page 10: 2 & PHP 7.0 - Magento · Switching a Magento site to PHP 7.1 • TEST, TEST, TEST. Then TEST again • If possible: install a new server, roll over to production –If you must replace

PHP Version Adoption

Page 11: 2 & PHP 7.0 - Magento · Switching a Magento site to PHP 7.1 • TEST, TEST, TEST. Then TEST again • If possible: install a new server, roll over to production –If you must replace

Benchmark Time!

Page 12: 2 & PHP 7.0 - Magento · Switching a Magento site to PHP 7.1 • TEST, TEST, TEST. Then TEST again • If possible: install a new server, roll over to production –If you must replace

Some Backwards Compatibility Pitfalls

• Extensions and custom code may not support PHP 7.x

• New reserved keywords

• Uniform Variable Syntax introduces changes to order of precedence

of complex variable variable dereferencing, e.g.

Expression Old Meaning New Meaning

$$foo['bar']['baz'] ${$foo['bar']['baz']} ($$foo)['bar']['baz']

$foo->$bar['baz'] $foo->{$bar['baz']} ($foo->$bar)['baz']

Page 13: 2 & PHP 7.0 - Magento · Switching a Magento site to PHP 7.1 • TEST, TEST, TEST. Then TEST again • If possible: install a new server, roll over to production –If you must replace

Switching a Magento site to PHP 7.1

• TEST, TEST, TEST. Then TEST again

• If possible: install a new server, roll over to production

– If you must replace PHP on your old node, expect downtime

• Monitor your store before and after switching to ensure a

smooth transition </plug>

Page 14: 2 & PHP 7.0 - Magento · Switching a Magento site to PHP 7.1 • TEST, TEST, TEST. Then TEST again • If possible: install a new server, roll over to production –If you must replace

HTTP/2Or: why I can no longer use telnet to browse the Web?

Page 15: 2 & PHP 7.0 - Magento · Switching a Magento site to PHP 7.1 • TEST, TEST, TEST. Then TEST again • If possible: install a new server, roll over to production –If you must replace

What is HTTP/2?

• May 2015: Published as RFC

• Does not change HTTP’s semantics

• Binary protocol, most implementations are HTTPS only

• Currently supported by all major browsers, many servers and CDNs

• Main new capabilities include:

– Multiplexing

– Header Compression

– Server Push

Page 16: 2 & PHP 7.0 - Magento · Switching a Magento site to PHP 7.1 • TEST, TEST, TEST. Then TEST again • If possible: install a new server, roll over to production –If you must replace

HTTP/2 Adoption

Page 17: 2 & PHP 7.0 - Magento · Switching a Magento site to PHP 7.1 • TEST, TEST, TEST. Then TEST again • If possible: install a new server, roll over to production –If you must replace

What is Multiplexing?

Browser

GET / img1.png

TCP Connection 1

/ img1.png OK

GET / img2.png

TCP Connection 2

/ img2.png OK

GET / img3.png

GET / img4.png

HTTP Server

HTTP/1.x: Messages are sequential and unidirectional

Page 18: 2 & PHP 7.0 - Magento · Switching a Magento site to PHP 7.1 • TEST, TEST, TEST. Then TEST again • If possible: install a new server, roll over to production –If you must replace

What is Multiplexing?

• In HTTP/1.1: Single TCP connection *can* do multiple requests, but

must do them in sequence

• HTTP/2 is multiplexing - multiple “dialogues” can happen on a single

connection concurrently

• This can have a massive performance boost, especially for static, IO

bound content

Page 19: 2 & PHP 7.0 - Magento · Switching a Magento site to PHP 7.1 • TEST, TEST, TEST. Then TEST again • If possible: install a new server, roll over to production –If you must replace

What is Multiplexing?

HTTP/2: Messages are interleaved in a bidirectional protocol

HTTP ServerBrowser

TCP Connection 1

Page 20: 2 & PHP 7.0 - Magento · Switching a Magento site to PHP 7.1 • TEST, TEST, TEST. Then TEST again • If possible: install a new server, roll over to production –If you must replace

More Benchmarks!

• 70% of tested stores showed improvement in full load time (avg.

improvement 12%)

• 45% also became interactive faster (avg. improvement 14.5%)

• Some sites (15%) actually showed a marginal decrease in

performance

All tests done on real Magento 2.x sites running PHP 7.x and

HTTP/2

Page 21: 2 & PHP 7.0 - Magento · Switching a Magento site to PHP 7.1 • TEST, TEST, TEST. Then TEST again • If possible: install a new server, roll over to production –If you must replace

Cranking it Up To 11: Server Push

// Push style.css along with this response

header("Link: </static/style.css>;rel=preload", false);

Browser

TCP Connection 1

HTTP Server

Page 22: 2 & PHP 7.0 - Magento · Switching a Magento site to PHP 7.1 • TEST, TEST, TEST. Then TEST again • If possible: install a new server, roll over to production –If you must replace

Converting a Magento Site to HTTP/2

• HTTP/2 is generally compatible with any Web platform or application

• You must have HTTPS support with a recent TLS

– yeah, you should have that anyway

• Supported by Apache 2.4 and Nginx 1.10

– You may need to use a custom package if not provided by your distro

• ALPN requires OpenSSL 1.0.2 or newer

• You can disable static file inlining from the Magento Admin

Page 23: 2 & PHP 7.0 - Magento · Switching a Magento site to PHP 7.1 • TEST, TEST, TEST. Then TEST again • If possible: install a new server, roll over to production –If you must replace

Setting Up HTTP/2

Apache 2.4

LoadModule http2_module

modules/mod_http2.so

<VirtualHost ...>

ServerName test.example.org

Protocols h2 http/1.1

</VirtualHost>

Nginx 1.10

server {

server_name

test.example.com;

listen 443 ssl http2;

}

Page 24: 2 & PHP 7.0 - Magento · Switching a Magento site to PHP 7.1 • TEST, TEST, TEST. Then TEST again • If possible: install a new server, roll over to production –If you must replace

TakeawaysThe tl;dr version

Page 25: 2 & PHP 7.0 - Magento · Switching a Magento site to PHP 7.1 • TEST, TEST, TEST. Then TEST again • If possible: install a new server, roll over to production –If you must replace

Takeaways

• Performance matters!

• HTTP/2

– Offers a significant speed boost to static content loading

– Will allow you to get rid of some outdated optimization techniques

– Switch to it, especially if you’re not using a CDN

• PHP 7.x

– Is much much (much) faster than PHP 5.6

– Is the future of PHP. Security fixes for PHP 5.6 end by the end of 2017

– Migration is not always trivial, make sure you plan ahead

– Expect some breakage especially in 3rd party extensions. Test heavily

– All new sites should be built with 7.x. Seriously

Page 26: 2 & PHP 7.0 - Magento · Switching a Magento site to PHP 7.1 • TEST, TEST, TEST. Then TEST again • If possible: install a new server, roll over to production –If you must replace

Thank You!

[email protected]

@shevron

https://www.shoppimon.com ( HTTP/2)

Page 27: 2 & PHP 7.0 - Magento · Switching a Magento site to PHP 7.1 • TEST, TEST, TEST. Then TEST again • If possible: install a new server, roll over to production –If you must replace