WPSFO: Nginx

Yesterday was my third time attending the SF WordPress Meetup. The main presenter was Floyd Smith, who co-authored the book WordPress in Depth with Michael McCallister. With him is pre-sales engineer Kunai Pariani, product marketer Faisal Memon, and digital marketing manager Patrick Nommensen.

There is a lot of Nginx people in the room that day.

Several terms were repeated several time during the talk, including how Nginx works with WordPress, microservice, performance, and redirection. Floyd mentioned that htaccess is the greatest and worst thing ever invented, which was hilariously true in so many ways. Nginx is suppose to help with that, plus ops, which all sounded pretty neat. Prior to the talk, the only thing I know about Nginx is that it is some sort of server, and that Docker supports its deployment (They use it as an example practice in its tutorial, if I recall it correctly).

Ok, let’s hear about Nginx.

There are apparently 2 level of Nginx – open source and Plus. Most of the services are in the open source, though. The original developer started it for his website. He set out to solve a specific problem, and he wanted others to use his solution, so he made it open source. That practice have remained consistent to this day. The solution did took a while for the community to catch on, since he was from Russia and everything was typed in Russian! It had since greatly expanded, and now part of their office is just 2 blocks away from us at the Automattic HQ!

So what’s Nginx about and what problem does it solved?

It was designed originally to solve the mathematical problem C10K – how to handle large amount of web traffic all at one time. It is a web server that also have various other uses, including serving as reverse proxy server that handle communication between clients and web servers. Architected for high demand, over 48% of the top 10,000 most visited websites uses it. Even WordPress itself is powered by Nginx.

So, umm, what does does it do other than being a web server?

Performance was mentioned several time throughout the talk. Nginx’s features often relates to that. Floyd talked quite a bit about load balancing and caching. One action that Nginx does, for load balancing, is that it performs health check and distribute traffic to the least busy server. There are two type of caching. The first is static file caching where static files is saved into a separate server and display when needed. The second type is dynamic caching, which create a cache after a user access the site, and that cache are what other users sees for a certain amount of time. With the later, though less loading are used, the method is not suitable for sites where each seconds matter. One of the example Floyd provided is stock market.

Another matter that he discussed is security and access control. Nginx can also act as reverse proxy server. The reverse proxy server can then become the main location for configuration changes and security implementation instead of the app server, adding an additional layer of security. In particular, Nginx also heavily encourages SSL, providing multiple SSL features, including implementation of SSL between microservices.

For a stack system that uses Nginx, Floyd calls it the LEMP Solution. (For eNginx, since LNMP is not pronounceable).

A system that uses Nginx has four benefits:

  1. Use of permalink instead of .htacess: easier to change path
  2. Ngnix can be configured for FastCGI: better caching.
  3. Security on Ngnix: allow the use of revise proxy server as a place for configuration changes.
  4. Nginx works great with WordPress Multisite in setting up proper file structure.

We talked about history, features, and stack system. But, how do Nginx fair in a multi-server environment?

Floyd asked the room if anyone have a Hardware ADC, the immediate response was “Heh?”.

One person did raised his hand, then promptly answered “Yea, as a paperweight!”

Predictably, the whole room laughs. Turns out ADC stands for App Delivery Controller. From the talk, it sounds like its some sort of device that allocates overflow of network traffic. A quick google reveals a wiki page that states ADC:

is a computer network device in a datacenter, often part of an application delivery network (ADN), that helps perform common tasks such as those done by web sites to remove load from the web servers themselves. Many also provide load balancing. ADCs are often placed in the DMZ, between the firewall or router and a web farm.

Tom’s IT Pro also have a detailed and more technical article on it: A Guide to Application Delivery Controller (ADC) Solutions.

Alas, the conclusion is that Hardware ADC is not exactly the most popular method. Most people prefer to use Software ADC so they can immediately get the service instead of waiting for a physical hardware to be mailed over.

This is where Nginx comes into play – it provides Software ADC services. For those who uses Microservices, that can be very useful.

I have been hearing a lot more about Microservices since I first learned about it during Devweek. It is definitely something that seems to be catching on, which makes sense. With the web expending, going microservices instead of monolith would give an large organization a much easier time of expending. According to Floyd, he believe that while WordPress and Automatic are not there yet, the two can make a blended approach of their existing monolith with microservice, especially since WordPress was designed to be opposite of a monolith approach to begin with. He then points to an Nginx article on microservices: Introduction to Microservices. He recommended WordPress users to read the last article there because we tend to be expert of modifying existing app, which is quite true in my case – my first job for WP is about working with existing site and plugins, after all. I’ve got Building Microservices by Sam Newman on Safari Online in my reading list (suppose to be pretty good), but for a quick read, this set of article seems good.

Q&A!

Things that caught my interest during Q&A:

  • For learning Nginx, in addition to Googling (the most useful skill for any self-learners!), Nginx’s mailing list are great. They also have official training for those whom prefer official things.
  • An attendee added that Apache and Ngnix are actually very similar, so learning it with an existing background in Apache would help.
  • WordPress approach tends to be more experimental, while Ngnix tends to be more strict. If there are users who wants to experiment it, containerized them may be a good idea.
  • Nginx does not intent to support htaccess – it is oriented to larger site.
  • Nginx is also not intended for real time, End-to-End Optimization. An attendee added – pretending to be whispering loudly – that if real time is needed, WordPress wouldn’t be used. Generally, people would use something like WebSocket.

Well, that concludes a quick basic info session on Nginx!

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.