Wednesday, November 29, 2017

PHP-FPM tuning: Using ‘pm static’ for Max Performance

Let's take a very quick look at how best to set up PHP-FPM for high throughput, low latency, and a more stable use of CPU and memory. By default, most setups have PHP-FPM’s PM (process manager) string set to dynamic and there’s also the common advice to use ondemand if you suffer from available memory issues. However, let's compare the two management options based on php.net’s documentation and also compare my favorite for high traffic setup --- static pm:

  • pm = dynamic: the number of child processes is set dynamically based on the following directives: pm.max_children, pm.start_servers, pm.min_spare_servers, pm.max_spare_servers.

  • pm = ondemand: the processes spawn on demand when requested, as opposed to dynamic, where pm.start_servers are started when the service is started.

  • pm = static: the number of child processes is fixed by pm.max_children.

See the full list of global php-fpm.conf directives for further details.

PHP-FPM Process Manager (PM) Similarities to CPUFreq Governor

Now, this may seem a bit off topic, but I hope to tie it back into our PHP-FPM tuning topic. Okay, we’ve all had slow CPU issues at some point, whether it be a laptop, VM or dedicated server. Remember CPU frequency scaling? (CPUFreq governor.) These settings, available on both *nix and Windows, can improve the performance and system responsiveness by changing the CPU governor setting from ondemand to performance. This time, let's compare the descriptions and look for similarities:

  • Governor = ondemand: scales CPU frequency dynamically according to current load. Jumps to the highest frequency and then scales down as the idle time increases.

  • Governor = conservative: scales the frequency dynamically according to current load. Scales the frequency more gradually than ondemand.

  • Governor = performance: always run the CPU at the maximum frequency.

See the full list of CPUFreq governor options for further details.

Notice the similarities? I wanted to use this comparison first, with the aim of finding the best way to write an article which recommends using pm static for PHP-FPM as your first choice.

With CPU governor, the performance setting is a pretty safe performance boost because it’s almost entirely dependent on your server CPU’s limit. The only other factors would be things such as heat, battery life (laptop) and other side effects of clocking your CPU frequency to 100% permanently. Once set to performance, it is indeed the fastest setting for your CPU. For example read about the ‘force_turbo’ setting on Raspberry Pi, which forces your RPi board to use the performance governor where performance improvement is more noticeable due to the low CPU clock speeds.

Using ‘pm static’ to Achieve Your Server’s Max Performance

The PHP-FPM pm static setting depends heavily on how much free memory your server has. Basically, if you are suffering from low server memory, then pm ondemand or dynamic may be better options. On the other hand, if you have the memory available, you can avoid much of the PHP process manager (PM) overhead by setting pm static to the max capacity of your server. In other words, when you do the math, pm.static should be set to the max amount of PHP-FPM processes that can run without creating memory availability or cache pressure issues. Also, not so high as to overwhelm CPU(s) and have a pile of pending PHP-FPM operations.

Linux top php-fpm static pm

In the screenshot above, this server has pm = static and pm.max_children = 100 which uses a max of around 10GB of the 32GB installed. Take note of the self explanatory highlighted columns. During that screenshot there were about 200 ‘active users’ (past 60 seconds) in Google Analytics. At that level, about 70% of PHP-FPM children are still idle. This means PHP-FPM is always set to the max capacity of your server’s resources regardless of current traffic. Idle processes stay online, waiting for traffic spikes and responding immediately, rather than having to wait on the pm to spawn children and then kill them off after x pm.process_idle_timeout expires. I have pm.max_requests set extremely high because this is a production server with no PHP memory leaks. You can use pm.max_requests = 0 with static if you have 110% confidence in your current and future PHP scripts. However, it’s recommended to restart scripts over time. Set the number of requests to a high number since the point is to avoid pm overhead. So for example at least pm.max_requests = 1000 depending on your number of pm.max_children and number of requests per second.

The screenshot uses Linux top filtered by ‘u’ (user) option and the name of the PHP-FPM user. The number of processes displayed are only the ‘top’ 50 or so (didn’t count), but basically top displays the top stats which fit in your terminal window --- in this case, sorted by %CPU. To view all 100 PHP-FPM processes you can use something like:

top -bn1 | grep php-fpm

Continue reading %PHP-FPM tuning: Using ‘pm static’ for Max Performance%


by Hayden James via SitePoint

#318: Backwards Compatibility Is Holding The Web Back

Frontend Focus
Issue 318 — November 29, 2017
A deep exploration of creating accessible menus for the Web, starting from defining exactly what a menu even is.
Smashing Magazine

A really neat look at a technique for using CSS and data attributes to create annotated ‘wireframe’ views of Web page elements.
Eric Meyer

Get expert database support immediately so that your applications aren’t crippled by database downtime. Percona Support ensures your database has cost-effective, enterprise-class support from the most trusted team of experts in the business.
Percona   Sponsor

The what, why, and how behind using a library for efficient ‘scrollytelling’ that uses IntersectionObserver in favor of scroll events.
Russell Goldenberg

Christian explores “the issue of the web not moving fast enough for people and clinging on to seemingly terrible ideas from the past”.
Christian Heilmann

Mitch takes a close look at PWAs on Android devices and explains how we can pave the way for a new era of ‘browserless’ web browsing.
Smashing Magazine

Stands for First, Last, Invert, Play. It's a technique for animating DOM elements smoothly.
David Khourshid

A golden-oldie set of pros, cons and helpful tips spanning the various ways of loading Web fonts on your site.
Zach Leatherman

Jobs

  • Software Engineer – Web Clients, ReactJS+ReduxJoin a growing engineering team that builds highly performant video apps across Web, iOS, Android, FireTV, Roku, tvOS, Xbox and more! Discovery Digital Media
  • Software Engineer Indeed Prime is a free service that helps engineers secure top offers from leading companies.  Indeed Prime

In Brief

HTML Media Capture Now a W3C Proposed Recommendation news
An HTML form extension for accessing a device’s media capture features via a file upload control.
W3C

Bruce Lawson on Editing The W3C HTML5 Spec news
Also explains why there are both WHATWG and W3C HTML specs.
Bruce Lawson.

Building A Simple To Do Web App with Stitch, React, and MongoDB tutorial
This short tutorial will get you started with MongoDB Stitch.
mongodb  Sponsor

Better Date Formatting with the 'time' Element tutorial
Adam Laki

Common Responsive Layouts with CSS Grid tutorial
Some common responsive website layouts to copy, edit, and mess around with.
Jo Franchetti

Monitoring Unused CSS Using The Power of the DevTools Protocol tutorial
Johnny's Dev Blog

Web Animation API: Unleashing The Power of CSS Keyframes in JavaScript tutorial
JavaScript Kit

Rendering Performance From The Ground Up video
An easy to understand introduction to performance concerns when rendering in the browser.
Martin Splitt

Can Firefox Quantum Regain Mozilla's Browser Market Share? opinion
Amos B. Batto

On the Growing Popularity of Atomic CSS opinion
Ollie Williams

SuperTinyIcons: 81 Popular Web Service Icons in Tiny SVGs tools
Minuscule SVG versions of common site and app logos.
Terence Eden

Set Up a Netflix Style Streaming Service for Any Device or Platform tools
The Bitmovin Player has a unified config, UI and API to deliver a perfect experience anywhere.
Bitmovin  Sponsor

nanocal: An AirBnB-Style Date Range Picker code
Live demo here.

UPNG.js: Now Even Better PNG Minification code
6x faster than before and creates better palettes for dithering.
Photopea

Literally Canvas: An HTML5-Based Drawing Widget code

Infinitown: An 'Infinite Town' WebGL Experiment demo
Little Workshop


by via Frontend Focus

Create the Perfect Carousel, Part 3

#185: Designing for a 'Browserless' Web

Mobile Dev Weekly November 29, 2017   #185
Chris Brandrick recommends
Designing for a 'Browserless' Web — Mitch takes a close look at PWAs on Android devices and explains how we can pave the way for a new era of ‘browserless’ web browsing.
Smashing Magazine
Peter Cooper recommends
AWS AppSync: Build Data-Driven Apps with Real-Time and Offline Capabilities — A fully managed serverless GraphQL service for real-time data queries, synchronization, communications and offline programming features, aimed at mobile app developers.
Tara Walker
Peter Cooper recommends
Engaging Users Through High Quality AMP Pages — From February next year, Google will enforce that AMP page content is comparable to the original, canonical pages’ content to ensure AMP pages are not used maliciously.
Google
Sponsored
State of Production Database Performance 2017 — In this report we explore and definitively answer whether MySQL or PostgreSQL is truly faster than the other.
VividCortex

Holly Schinsky recommends
Using CSS Grid: Supporting Browsers Without Grid — CSS Grid might provide one of the biggest recent improvements in front-end development, but how can we gracefully deal with browsers that don’t support it?
Rachel Andrew
Brian Rinaldi recommends
Progressive Web Apps: A Crash Course — Ahmed Bouchefra explains PWAs by showing how to build one from scratch with ES6 and React, optimizing it step by step with Lighthouse for UX and performance.
SitePoint
Peter Cooper recommends
Kotlin/Native 0.4: Kotlin Can Now Use Objective C APIs — This essentially makes it easy to use Kotlin to build native iOS apps.
JetBrains
Mobile Web
Holly Schinsky recommends
JavaScript Performance Optimization Tips: An Overview — Ivan digs into JavaScript performance, from environments, response times, context, parsing, compiling and executing, to bundle sizes and shipping less code.
Ivan Čurić
Chris Brandrick recommends
Take Control of Your Scroll: Customizing Pull-to-Refresh and Overflow Effects — The overscroll-behavior property overrides the browser’s default overflow scroll behavior when reaching the top/bottom of content. Currently in Chrome 63+ only.
Google Developers
Brian Rinaldi recommends
Common Responsive Layouts with CSS Grid — Some common responsive website layouts to copy, edit, and mess around with.
Jo Franchetti
Brian Rinaldi recommends
Installing Progressive Web Apps — Trying to get the balance right between discoverability and intrusiveness.
Jeremy Keith
Hybrid Apps
Brian Rinaldi recommends
Ionic From Scratch: Getting Started With Ionic — How to set up an Ionic development environment on your computer and create an Ionic project.
Tinashe Munyaka
Peter Cooper recommends
Ionic vs React Native – What's The Best Choice for Your Hybrid Mobile App? — A comparison of Ionic and React Native, both of which are seen as “key frameworks in each of their respective fields of hybrid app development”.
Gareth Dunne
Chris Brandrick recommends
Integrating an Ionic App with a Node Backend
Josh Morony
Native Development
Holly Schinsky recommends
Why Flutter Will Take Off in 2018 — 5 reasons why Flutter (a new mobile app SDK alternative to React Native using Google Dart) will be a game changer for mobile app development in 2018.
Nick Manning
Brian Rinaldi recommends
Secure Coding in Swift 4 — A secure coding guide addressing changes in Swift 4 as well as the new tooling options available in Xcode 9 that help mitigate security vulnerabilities.
Collin Stuart
Holly Schinsky recommends
An In-Depth Introduction to React Native — A ‘show and tell’ in-depth video introduction to React Native.
Tim Ermilov
Brian Rinaldi recommends
How to Upload Pics to Firebase from an Android App
Chinedu Izuchukwu
Brian Rinaldi recommends
Converting An Android App to Kotlin
Igor Ganapolsky


by via Mobile Dev Weekly

The DIY Filmmaker's Toolkit - #infographic

For the cash-strapped filmmaker who has the ambitious vision but lacks a Hollywood budget, here's a handy guide to do-it-yourself production equipment and tools.

[ This is a content summary only. Visit our website http://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Web Desk via Digital Information World

Luca Pederzini

Minimal One Pager with a clean interactive slider of images for architect, Luca Pederzini.

Full Review | Direct Link


by Rob Hope @robhope via One Page Love

LAMP IN ROOM

Bright e-shop which helps you choose lighting for your home. Gigabytes of photo, video reviews and 360º. Real experts will help you find the lamp from your photo better than Google pics.


by csreladm via CSSREEL | CSS Website Awards | World best websites | website design awards | CSS Gallery