Application Acceleration: Give Users What They Want

Original: https://www.nginx.com/blog/application-acceleration-give-your-users-what-they-want/

Technology is evolving at an unprecedented rate and users are demanding app acceleration more than ever before. Research shows that a 1‑second increase in the time it takes a web page to load can result in 11% fewer page views, 7% fewer conversions, and a 16% decrease in customer satisfaction. The concept is simple: users will not spend their valuable time or money on your website or app if it’s slow. If you can’t deliver content fast, you can’t serve your customers. The bottom line is that application performance and application survival is all about serving at the pleasure of the user.

ebook2-cta

NGINX and NGINX Plus, the modern web server and load balancer used by over 40% of the most popular websites in the world, can help optimize the delivery and performance of your applications. NGINX was created to solve the C10K problem – the challenge of serving 10,000 simultaneous users on a single web server instance.

NGINX has a event‑driven, modular, single‑threaded, and asynchronous architecture that scales extremely well on commodity hardware. NGINX uses the underlying power of modern operating systems, like Linux, to efficiently manage the usage of memory, CPU, and network bandwidth for maximum app acceleration. Together, the optimizations in NGINX enable it to serve at least 10x more (and often 100–1000x more) requests per server compared to traditional solutions.

Simple Ways to Improve Application Speed & Performance

Caching and Logging

Caching static files like JavaScript, CSS, and images in your user’s browser cache can really help with performance. This can be easily implemented by adding an expiration time to the response header of static file requests.

Static file management can be optimized even further. Disabling file logging for static files like stylesheets and images can significantly improve disk I/O. In most cases it’s not necessary to log static file requests, so you can use the access_log directive to disable it.

location ~* \.(ico|js|css|png|gif|jpe?g)$ {
    expires 7d;
    access_log off;
}

NGINX is also great for caching requests that aren’t static, and distributing them via a load balancer. This is useful for improving speed and performance for websites and applications like WordPress and NodeJS. The caching options are customizable and enable you to specify which requests to cache, when to limit or bypass caching, and more.

Enabling Keepalives

Enabling keepalive connections for web acceleration is another important way to improve website and application performance. With NGINX, it’s possible to maintain 10,000 connections with about 2.5 MB of memory. This means you can increase the value of the keepalive_timeout directive significantly without fear of running out of memory.

keepalive_timeout 65;

From a user performance perspective, the goal is to allow for as many keepalive connections as possible. To learn much more about this topic, see HTTP Keepalive connections using NGINX for web performance in HTTP Keepalive Connections and Web Performance.

Compressing Files

GZIP compresses assets before delivering them to the users who requested them. It’s an important component of web acceleration because it can reduce the sizes of pages and stylesheets significantly, up to 70%. This saves bandwidth, but more importantly it reduces the time it takes for web assets to reach your users because the physical size of the asset is smaller.

Unless you have special requirements, simply including the gzip on directive in the configuration is most effective. You can use the gzip_comp_level directive to set a higher compression level (such as 6), but that doesn’t necessarily improve performance. Compression level 6 is roughly twice as slow as level 1, but the difference in copmression ratio is only about 4%. By default, NGINX compresses responses only for the text/html MIME type. You can use the gzip_types directive to specify additional MiME types to compress. For more information about GZIP optimization, see Compression and Decompression in the NGINX Plus Admin Guide.

server {
    gzip on;
    gzip_comp_level 1;
    gzip_types text/plain text/css application/json application/x-javascript text/xml 
               application/xml application/xml+rss text/javascript;
}

Reminder: As with any configuration change, you need to reload the NGINX configuration for these settings to take effect.

NGINX and NGINX Plus can help you accelerate your apps to meet the demands of users, whether you are using it as a simple web server or in a complex load‑balancing setup. We’ve discussed just a few of the ways you can improve the performance of your applications. To learn more about how a slow application can impact your business, download our ebook, It’s All About the User … And Other Facts You Can’t Ignore, try these simple steps, and let us know what you think!

Retrieved by Nick Shadrin from nginx.com website.