Useful Snippets

Welcome!


This blog is used to collect useful snippets related to Linux, PHP, MySQL and more. Feel free to post comments with improvements or questions!

Are your smart devices spying on you? Make better purchasing choices and find products that respect your privacy at Unwanted.cloud

RSS Latest posts from my personal blog


Subscribe to RSS feed


Mark Jaquith: Next Generation WordPress Hosting Stack – Summary and highlights

Stanislav KhromovStanislav Khromov

Mark Jaquith gave an interesting talk on the future of the WordPress hosting stack at WordCamp Europe 2014 last week. Let’s see what the future holds!

WordPress is dynamic, and that’s both a strength and a weakness

WordPress has little cache built-in by default. There is only a non-persistent, in-memory Object Cache. Most data is fetched from database and processed on every request.

“Old-style” hosts can’t deliver the performance modern sites need

Old “cPanel-style” hosting isn’t equipped to handle high-performance WordPress. Specialized stacks do a much better job.

americans-don-t-have-time-for-slow-websites-infographic--ba3d727bea

People don’t like slow sites

Reducing your TTFB is crucial.

Guidelines for page generation speed:

WordPress Managed Hosting

Managed Hosting – a new breed of hosting providers tailored to WordPress.

In addition, you can purchase a VPS where you can customize the stack yourself. When choosing a VPS, use a reputable company, as many are fly-by-night and may disappear at any time.

Some reputable VPS providers:

stockvault-flying-particles158027

Basics of a high performance WordPress stack

nginx

nginx is a fast web server that uses little resources. It support SPDY, which improves loading sites with many assets (css, js, images) through pipelining. nginx also supports load-balancing and caching.

php-fpm or HHVM

nginx does not have php baked into it. this is good, since it reduces memory usage for static requests as compared to Apache with mod_php. Always use the latest PHP version – newer PHP versions have increased performance and built-on opcache.

An alternative is HHVM – a PHP implementation created by Facebook, which aims to improve performance. (up to 5x faster than regular PHP!) It’s fully compatible with WordPress core, but may not support all third party plugins.

Caching fundamentals

Caching is about doing as little as possible for as many users as possible without visibly affecting how dynamic the site feels to users.

Full page caching

Most cache plugins use full page caching, showing a pre-saved version to anonymous visitors.

Full page caching may be utilized at different levels of the stack:

Marks own cache settings using Nginx and php-fpm:
https://gist.github.com/markjaquith/04162825d159c8fb5534

Object Cache

Persistent caches include:

Object caching is used extensively in core and is also available to plugins.

MySQL performance

MySQL is usually not the bottleneck – PHP performance is.

mysqltuner.pl – Gives you tips on improving MySQL performance!

HyperDB – replaces the built-in WordPress database layer. Can talk to multiple MySQL servers, has failover, sharding and much more! WordPress.org uses this.

But make sure you enable the MySQL query cache.

There are drop-in alternatives to MySQL like Percona and MariaDB, which can improve performance for some sites.

Making a stack

Mark presented a few stacks that build on the basic stack.

nginx-php

Nginx + PHP

Static files are served by Nginx and PHP requests go through to php-fpm or hhvm. The easiest stack.

sandwich

Nginx + Varnish + Nginx + PHP

Nicknamed the “nginx sandwich”. This variant uses Varnish for caching. nginx is used at the front because Varnish does not support SSL. It’s also possible to add HAProxy to the mix to load balance between multiple servers.

And finally, the big reveal:

The future hosting stack

wp-hosting-stack

The combo of choice is nginx + hhvm + mysql + redis.

This stack allows you to scale horizontally when required and has high performance.

Other useful stuff

Mark showed off a few useful functions that he had built.

Full-stack impostor syndrome sufferer & Software Engineer at Schibsted Media Group

Comments 0
There are currently no comments.