Over time, any web developer ( blogger, web designer or web programmer) will need a special test site where you can practice without any problems website development or testing another web project. Some beginners use the resources of their paid hosting and place at least two websites there. One worker ( basic), and the other ( additional) for testing. The test site undergoes various tests ( installation and testing of many plugins, themes, scripts and so on).

As a result, with this layout, the main production site suffers greatly, since most of the hosting resources are consumed by the test project. However, there is another way that will allow without loss ( both in monetary and resource terms) carry out testing of your sites, and we will now consider this method.

Why not?

You probably already know that in order to put your website on the Internet, you need to register a domain name, buy hosting, that is, disk space on some computer with a high-speed connection on which they can work PHP scripts. For sites to function fully, PHP and MySQL must be installed. All this is not available on regular computer. How can HTML and PHP files run on your computer?

A regular file can be opened with Notepad++ or even with Notepad. Write something inside, save it and then open it without any problems this file on your browser and see how this file would look on a hosting site on the Internet. That is, we already see the working HTML page. In it we can create certain designs, content and monitor the project without an Internet connection. Essentially, we already have everything. If we want to run PHP file using a browser, then nothing will work for us, since PHP scripts in operating system Windows will not work without additional software.

All this is not available on a regular computer, and thus there is no possibility of working with your web projects. Therefore, some beginners start spending money on additional resources of their paid hosting. But what to do in this case? The answer is simple - they exist special programs, with which you can install your own dedicated server directly on your computer.

What is a server?

What's happened server and how is it different local server from what is on the network. In our case, a server does not mean a computer, but a special set of programs that provide optimal performance site. In order for the site to work, we will need to install it in a special designated location on the server (). That is, we upload site files to remote computer. However, without special server programs, our uploaded files will not be visible on the network. Now for such purposes we will create own server on your home computer.

For this we need special programs. But which ones are better suited and what difficulties can they cause during further work? For your information, below I list the best web servers by popularity around the world. However, this does not mean that they need to be installed immediately. I'll explain why later!

List of the best web servers

There are currently several solutions on the market from a variety of manufacturers:

  • (website - apache.org) is the most common and popular free server online. It is more reliable and flexible. The server is not demanding on processor resources and is capable of serving many sites. The application is available for a wide range of operating systems, including Unix, Linux, Solaris, Mac OS X, Microsoft Windows and others. Apache usage currently stands at 71%. However, this is a complex program that not every beginner can handle.

  • (website - www.iis.net) - one more reliable server from Microsoft. It firmly settled into second place with 14% of online usage. After installing the program, only two programming languages ​​will be supported ( VBScript and JScript). However, you can open additional features, setting for this necessary extensions. With the installation of such modules, the functionality of this server is significantly increased.

  • NGINX (website - nginx.org/ru/) is the most popular web server on the Russian Internet. Compared to the first two, it is the simplest and does not have unnecessary functions. It is also praised for its reliability and high speed. The developer of this product is our compatriot Igor Sysoev. In 2004, he released the first version of nginx. Now this software product closes the top three most popular web servers in the world. Its usage is about 6.5%.

  • (website - litespeedtech.com) - this web server does not have extensive capabilities, but it has very high speed work. It is 9 times faster than the popular Apache. Much attention is paid to safety ( its own protection against system overload, strict checking of http requests, anti-ddos and much more). LiteSpeed ​​is available for Solaris, Linux, FreeBSD and Mac OS X. The program has a usage rate of 1.5%.

Of course, there are many other similar programs, but the share of their use and trust among users is not as high as these. Unfortunately, you won't be able to do this with just one program. Not only are they useful for large projects, but they can also be difficult to install and configure. In addition, in addition to such servers, separate installation and configuration of some programs is required ( for example, to work with a database). All this causes significant difficulties for many users. What to do in this case?

Local Server Features

At the moment, there are many different distributions that can make life easier for any novice webmaster. They are very easy to install, easy to operate, less demanding on resources and contain the necessary software elements for the best performance.

That is local server- this is not one program ( not one specific web server), but a special collection that includes lightweight versions of complex server programs. Typically the assembly includes: the server itself ( mostly Apache, but there may be others), PHP compiler ( with its help the browser can read the codes and assemble the page), components for working with databases, various installers and many other programs. All this makes things much easier than if we installed and configured each program separately.

In addition, separate modules can be connected to the basic packages of local servers to expand functionality. Another important feature is that on some servers it is possible to work from a removable flash drive. In general, such assemblies are very well suited for rapid website development and testing. small projects, and sometimes even large ones.

Review of popular local servers

Here are some builds that may be useful to you:

  • (website - denwer.ru) is a free domestic server that is designed to work with websites, web applications or Internet pages. Its developers are Dmitry Koterov and Anton Sushchev. This product contains the necessary distributions for simplified work. For example, this includes the Apache web server with various support, the phpMyAdmin panel and MySQL for working with databases and other programs. You can also work from a removable flash drive. Unfortunately Denwer only supports the Windows operating system.

  • XAMPP (website - www.apachefriends.org/en/xampp.html) is a special server build from Apache friends. The necessary distributions allow you to run a full-fledged web server on it. This program is distributed free of charge and supports work in Windows system, Solaris, Mac OS X and Linux. There are also the following advantages: the server is popular for its very simple user interface, which makes it a favorite for many beginners; there are multiple appearances of updated versions; the update process is very simple and user-friendly; There are additional modules. You can also download the required version from another official website - sourceforge.net/projects/xampp/files.

  • (website - www.appservnetwork.com) is an excellent server from a Thai manufacturer, the concept of which is easy installation and configuration of all distributions in 1 minute. The first release of the assembly took place in 2001 and since then the number of users has been growing all the time. AppServ is very easy to install, it works stably and is no worse than official and individual releases, and its reliable performance makes it possible to create a full-fledged web server on your computer.
  • (website - vertrigo.sourceforge.net) is another good and easy to install local server. The assembly is very flexible, has good performance and takes up little disk space. Unfortunately, it only works on Windows OS for now.
  • Zend Server Community Edition (website - www.zend.com) is a free server from Zend, designed to work with web applications. Contains all the necessary components for quickly deploying a local server on your computer.

  • (website - open-server.ru) is a domestic portable local server that has high functionality for the development and creation of websites and other web projects. Has a multilingual interface ( including Russian) and is designed to run on Windows OS. Work from removable media is supported. This server very good and serves as a good alternative to Denver.

  • (website - wampserver.com) - another good build with a Russian interface ( there are also other languages). There is a simple and clear menu, and convenient installation and configuration of the assembly does not cause any particular difficulties. Configuration can be done without affecting configuration files, which is very useful for novice webmasters. The server is distributed free of charge and only works on Windows platform. Unfortunately, portable version Not yet.
  • (website - easyphp.org) - a very simple assembly with Russian language support. The assembly is unremarkable, does not have huge functionality and is mainly intended for testing small projects. There is support for working from portable media. This server will serve as a good replacement for Denver.

Before you put a site or blog on the Internet, you should test it to see how correctly the site design will look, how the scripts and form will work feedback, plugins and so on.
This is the reason why many web developers ( bloggers, web designers or web programmers) use test sites where they conduct checks, tests, experiments, in general, any test work on a future project.
There are two ways to create test sites.
1. Test site on hosting
Some beginners use paid hosting to test projects, hosting two sites - one main (working) and the second additional, test.
Disadvantages of this method:
- lack of space on hosting;
- low Internet speed;
- you don’t always have money to buy paid hosting for testing projects.
2. Test site on your computer
This method, in my opinion, is the best. I want to look at it with you in more detail. First I'll talk about the advantages:
- does not require an Internet connection;
- no financial costs required
What is this test site on the computer? It's about local server, which is installed on your computer. Using a local server, you can quickly and easily test your project.

Someone might say: why even test your project through a local server? After all, just open the file “index.html” and we will see what the site will look like on the Internet. Yes, it’s true, this is enough, but if you use chats, forums, etc. on the site (WordPress, Joomla, drupal), then there is no way without a local server. Moreover, if you use a CMS engine (WordPress, Joomla, drupal) for your project, then you need not only PHP support, but also a MySQL database.

So, local server is a special set of programs that ensures the correct operation of scripts right on your computer. The assembly includes: the server itself, the PHP compiler ( with its help the browser can readphp code and process the page correctly), components for working with databases (Database) and many other programs.

I have prepared for you a list of popular local servers for the site. Read, rate, download and use.

List of popular local servers for the site.

Denwer is a free local server for testing websites, web applications or Internet pages. Denwer includes: Apache web server, phpMyAdmin and MySQL panel for working with databases (databases) and other programs.
The local Denwer server runs only on the Windows operating system.

You can download from the official website denwer.ru

XAMPP is a free local server for testing websites, web applications or Internet pages with a simple user interface. Supports work on Windows, Solaris, Mac OS X and Linux.

You can download from the official website www.apachefriends.org/en/xampp.html

AppServ- another free local server. Fast and easy installation.

You can download from the official website www.appservnetwork.com

VertigoServ- easy to install local server.
Works only on Windows operating system.

You can download from the official website vertrigo.sourceforge.net

Zend Server Community Edition- free local server.

You can download from the official website www.zend.com

Open Server is a free local server with high functionality for developing and creating websites. Runs on the Windows operating system.

You can download from the official website open-server.ru

Personally, I use a free local server. Why Denwer and not some other? Most likely a habit. I started with the local Denwer server, that’s why I use it only. And you need to choose which local server you will work with.

Download the local server, install it on your computer, read or watch a video lesson or instructions for use. Test your web projects and let them bring you a lot of income!

According to statistics from the W3techs project, more than 80% of web applications and sites run on open source servers. It’s not for nothing that “network dominance” is what Open Source proponents most often talk about when it comes to Linux’s market share.

Which projects should you pay attention to first? Which open servers are best suited for solving user problems?

e-Government expert Robin Mulvizhk offers five of the most popular open web servers on OpenSource.com.

Apache HTTP Server

In February 2015, this project celebrated its twentieth anniversary. It is the most popular web server in the world - according to W3techs, it runs 52% of all websites in the world.

The most common platform for Apache HTTP Server is Linux. But the application is multi-platform - the server can be deployed on OS X or Windows. The solution is built on a modular principle, so its functionality can be expanded if necessary. For example, using the mod_proxy module, a gateway is created on the server, the mod_proxy_balancer module balances the load for all supported protocols, and the mod_http2 module is responsible for HTTP/2 support.

The project is accompanied by excellent documentation and comprehensive support from other users. The solution is distributed under the terms of the Apache License v. 2.

NGINX

The development of this server began in 2002 by Russian programmer Igor Sysoev. The first public release of the application took place in 2004 and was essentially a response to the C10K problem - the task of building a high-performance server capable of simultaneously serving 10 thousand connections.

According to W3techs, this server is the second most popular open source solution in the world. A little more than 30% of all sites work on it.

More often system administrators choose NGINX for its high performance and scalability. The solution is perfect for handling multiple parallel sessions.

The application is distributed under the terms of a very short BSD-like license.

Apache Tomcat

Apache Tomcat - open application, developed by the Apache Software Foundation, is a servlet container that functions as a web server, thereby extending its functionality. Written in Java. Initially, the rights to the solution belonged to Sun Microsystems, which in 1999 donated them to the fund.

Typically, Apache Tomcat is used either as a standalone web server serving local files, or as an application server on Apache HTTP Server. According to W3techs, it is used by 1% of all Internet sites.

The application is distributed under the terms of the Apache License v. 2.

Node.js

Node.js development began in 2009 by Ryan Dahl. The project is currently managed by the Node.js Foundation with support from the Linux Foundation. According to W3techs, the market share of the solution is 0.2%.

Node.js is a platform for execution network applications and often plays the role of an independent web server. Thanks to its design features, it allows you to achieve high throughput and scalability for web applications running in real time, which is very important for browser games.

The application is distributed under the terms of the original license.

Lighttpd

The first release of this application dates back to March 2003. Like NGINX, the Lighttpd web server is capable of supporting 10 thousand connections simultaneously, which is made possible by processing them asynchronously. According to W3techs, this server powers 0.1% of all websites.

Distinctive features of Lighttpd are low CPU load and high optimization speed. The principles embedded in its operation make it possible to make the platform load independent of the number of current connections.

The solution is distributed under the terms of the BSD license.

Working with the Russian Apache Web server. Russian Apache

The most common Web server in the world is Apache. According to Netcraft ( http://www.netcraft.com/Survey/) the total number of Web sites operating under his control reached 2 million by the end of 1998 (55% total number nodes) and is constantly growing. For comparison: Microsoft servers account for 25%, Netscape -7%. Being free open program, designed for free Unix systems (FreeBSD, Linux, etc.), Apache by functionality and reliability are not inferior to commercial servers, and extensive configuration options allow you to configure it to work with almost any specific system. There are server localizations for various languages, including Russian.

Historically, Russian texts on the Internet can be presented in different encodings, of which the most common are koi8-r (or simply koi8) and Windows-1251: the first one works with most servers and workstations running Unix, the second one is standard for all Windows versions. Since the Windows-1251 encoding is naturally used on the vast majority of client machines, the share of those who travel through the Russian part of the WWW using koi8 now does not exceed 5%. However, documents are stored in this encoding on many Unix servers, and they are most often used to transmit mail messages and almost always - letters in a teleconference; many Russian-language IRC channels work with it (by the way, the abbreviation KOI stands for “information exchange code”). To solve the problems that arise when text encodings on the server and the client machine do not match, the Russian module Apache-RUS was created for the Apache Web server.

In this article we will look at the process of installing and configuring both the server itself and the mechanism for transcoding documents on the fly.

Installation

The latest version of Apache-RUS can be obtained at ftp://apache.lexa.ru/pub/apache-rus/ (the “major” part of the version number, for example 1.3.3, corresponds to the version of the original Apache, the “minor” part, for example PL27. 3, - the so-called patch level, i.e. version of the Russian module). It is recommended to install those versions that have proven themselves to be “stable”. Here the server setup is described using the example of Apache_1.3.3rusPL27.3.

So, first of all, we copy the archive (less than 1.5 MB) onto our machine and unpack it:

# ftp ftp://apache.lexa.ru/pub/apache-rus/ apache_1.3.3rusPL27.3.tar.gz

# tar xvzf apache_1.3.3rusPL27.3.tar.gz

After this, we enter the apache_1.3.3rusPL27.3 directory created during unpacking and run the configure script:

# cd apache_1.3.3rusPL27.3

If necessary, you can explicitly specify arguments to the script (a list of them is provided by the configure -help command). So, if you want to install the server in a directory other than the standard one, you need to run “configure -prefix=

Once configure is running, issue the make and make install commands as usual (these actions are performed by the root user).

Now the server is installed in the /usr/local/apache directory, but we cannot start it yet - first we must edit the httpd.conf, access.conf and srm.conf configuration files in the /usr/local/apache/etc/ directory (starting from version 27.4 - /usr/local/apache/conf).

Settings

Setting up the Web server configuration files is the most critical step when installing it. Here we will consider only the most common directives and their parameters, since a complete list with descriptions will take more than a dozen pages. The server rereads configuration files upon startup, as well as when it receives a -HUP (hard restart) or -uSR1 (soft restart) signal. If the server is in working condition, then when the configuration changes, it is recommended to restart it with the command

# kill -USR1 `cat /usr/local/apache/logs/httpd.pid`

In this case, existing connections are not closed forcibly and are completed in the usual way, and subsequent clients work with new configuration files.

access.conf file

access.conf contains directives that describe access rights to directories and files on the Web server. First of all, decide in which directory the documents will be stored. By default this is /usr/local/apache/share/htdocs, however many administrators prefer to place documents starting from the /www/ directory<имя_сервера>/, because with this organization it is easier to navigate the file structure. Let, for example, we create directories:

/www/radio-msu.net/

/www/people.radio-msu.net/

They will be the root for the corresponding virtual servers.

The access.conf file may contain sections Directory, Location and Files, which are limited by directives of the same name. The parameters of these directives can use the characters "?" and "*" as well regular expressions, preceded by a tilde, for example . The Directory section contains instructions related to a specific directory on the disk, the Location section contains instructions related to a virtual path, and the Files section contains instructions related to a file or group of files.

# directives that apply to all documents stored in

directory /www/rmt.ru and its attachments

# directives that apply to all documents available at http://<имя_сервера>/cgi-bin/<путь_к_файлу>

# directives related to the form.html file from the directory

The difference between the Directory and Location sections is that the former refers to directories on disk, the latter refers to the virtual path (URL) that the browser requests from the Web server. Both may contain order, allow and deny directives, which allow you to restrict access to a directory or URL from different machines.

The next two directives relate to the section .

Options

Possible values parameters:

    ExecCGI - allow execution of CGI scripts in this directory and its subtree;

    FollowSymLinks - allow following symbolic links (created by the ln command);

    Includes - allow SSI (Server Side Includes);

    Indexes - allow listing of a directory if it does not contain an index.html file (or an index file specified by the DirectoryIndex directive);

    MultiViews - allow support for multiple languages; it is disabled by default and, as a rule, there is no need to enable it; support for on-the-fly transcoding for the Russian language is installed using other directives, which we will look at later;

    All - install all listed modes at once except MultiViews.

If there are no special security requirements, it is quite acceptable to specify "Options All" in the section ; otherwise, you need to describe the parameters of each directory separately.

AllowOverride

Most directives can be set not only in server configuration files, but also in .htaccess files in server directories. The AllowOverride directive defines the set of directives allowed in .htaccess files. The following parameters can be specified:

FileInfo - allow directives responsible for document types;

Indexes - allow directives related to directory listings;

Limit - allow the allow and deny commands, which limit access to files depending on the address of the client computer;

Options - enable the Options directive described above.

Please note that when you enable the latter mode, users will be able to create their own .htaccess files and allow execution of CGI scripts in them. Therefore, if you need to control user CGI scripts, you should not extend the AllowOverride Options directive to user directories.

However, in many cases (in particular, when only the administrator has rights to change the contents of the server), the access.conf file may look like in.

srm.conf file

The srm.conf file contains directives related to general settings server directory structures. As a rule, it is enough to change only a few lines.

DocumentRoot<первый каталог сервера>

Path to the default directory, the index file of which the user will receive when accessing the server (http://<имя_сервера>/). This directive should also be set for each of the virtual servers (in the section httpd.conf file).

UserDir<имя пользовательского каталога>

The directory where users must place their files so they can be accessed at http://<имя_сервера>/~<имя_пользователя>/. Standard public_html. Sometimes, to make life easier for users, administrators give the "UserDir www" directive.

DirectoryIndex<список файлов индекса>

The index file is the file that will be passed to the client when accessing the directory. If you specify multiple names, the server will search for a matching file from left to right. By default, the list contains only one name - index.html, but it is customary to add other common index file names to it. For example, a directive might look like: DirectoryIndex .index.html index.html index.htm index.cgi index.shtml home.html home.htm default htm default html

To enable support for CGI scripts on the server, remove the comment mark before the ScriptAlias ​​and AddHandler cgi-script .cgi directives. The first specifies the directory on the disk in which the files will be stored. executable programs, and the second specifies that all files with the .cgi extension should be processed as scripts.

The ErrorDocument directive allows you to replace standard server error messages with your own. For example, in the case of the most common error - 404 (file not found) - it is considered good form to present the user with a page asking them to continue their journey through the server or a form for searching the site. This is implemented quite simply: in the server settings we remove the comment mark from the line

ErrorDocument 404 /missing.html

In the root directory of each virtual server, create a missing.html file. It is recommended to provide links to the main sections of the server - both for the convenience of users and in order to provide the necessary information search robots, indexing servers.

httpd.conf file

The httpd.conf configuration file is the main one and contains settings related to the operation of the Web server, virtual servers, and all its program modules. In addition, it is here that the transcoding of Russian letters is configured when transmitted from the server to the client and back.

The Port directive, placed at the very beginning of the file, specifies the port number for the http server; by default it is 80. If necessary, you can assign another port or several ports to the server, for which the Listen directive is used.

The HostnameLookups directive with the on or off parameter enables or disables the conversion of numeric IP addresses of clients that receive documents from the server to domain names. This conversion somewhat slows down the server, but with fewer than 10,000 visits per day, this is usually almost unnoticeable.

User Directives and Group specify the user who will administer the server. From a security point of view, it is not advisable to specify here an existing user who has access to any other resources or files. It's better to create a separate user and group specifically for the http server, for example:

The ServerRoot, ErrorLog, CustomLog directives define, respectively, the root directory of the http server, the path to the error log (error_log) and the path to the general log of requests to the server (access_log).

The CacheNegotiatedDocs directive allows caching of documents received from the server. By default, this mode is disabled, but since the bandwidth of domestic Internet channels will leave much to be desired for a long time, it would be good to enable it: then the user will not have to wait for images to load every time they access your page.

Configuring virtual servers in the httpd.conf file

In most cases, one http server is capable of processing requests coming to various so-called virtual Web servers. Virtual servers can have the same IP address, but different domain names, or different IP addresses. From the user's point of view, the second option is slightly more preferable, since the request to a server that differs from the main one only domain name, must contain its name, and some older browsers that do not support HTTP/1.1 (for example, Microsoft Internet Explorer 2.0) do not include this information in the request. However, such browsers are falling out of use (now they are less than 0.5% of the total number); on the other hand, assigning its own IP address to each virtual server may be an unjustified waste of the company's address space.

The ServerName, ServerAlias, NameVirtualHost and VirtualHost directives are used to describe the addresses and domain names of virtual servers. They are only needed if you need to install more than one virtual server.

http://www.apache.org/ - official server Apache developers

http://apache.lexa.ru/- server of the development team of the Russian Apache module

Hi, This article covers the 5 most popular options for setting up a server for a web application. What options are there and which one to choose?

There are many factors to consider when choosing a server environment, such as performance, scalability, availability, reliability, cost, and ease of management.

The article presents a set of the most commonly used server environments with their brief description, including pros and cons. All concepts can be used in different combinations with each other, and each environment has different requirements, so there is no single correct configuration.

1. Everything on one server

The environment is on the same server. For a typical web application, this will include a web server, an application server, and a database server. A special case of implementing this set is , the name of which is an abbreviation for Linux, Apache, MySQL and PHP, on a single server.

Usage example: Good for quickly deploying an application as it is the simplest configuration of all, but offers little in the way of scalability and component isolation.

Pros:

  • Simplicity

Cons:

  • The application and database share the same server resources (CPU, memory, I/O, etc.), which, in addition to potentially poor performance, makes it difficult to determine the source (application or database) of this poor performance.
  • It is difficult to scale horizontally.

2. Dedicated database server

The database management system (DBMS) can be separated from the rest of the environment to eliminate competition for server resources between the application and the database and to enhance security by removing the database from the DMZ, the public Internet.

Usage example: Good for quickly deploying an application, but also eliminates the problem of the application and database competing for the same system resources.

Pros:

  • The application and database do not compete for the same server resources (CPU, memory, I/O, etc.).
  • You can vertically scale each component (application and database) independently of each other by adding additional resources to the desired server.
  • With certain settings, this can improve security by removing the database from the DMZ.

Cons:

  • The installation process is a little more complex than with a single server.
  • Performance issues may occur if the network connection between two servers has a long response time (for example, the servers are geographically distant from each other) or there is insufficient bandwidth for the data being transferred.

3. Load balancer (reverse proxy)

Load balancers can be added to a server environment to increase performance and reliability by distributing the load across multiple servers. If one of the servers goes down, other servers will process incoming traffic until the downed server is up and running again. A load balancer can also be used to serve multiple applications over the same domain and port using a reverse proxy.

Examples of reverse proxy-supporting software include HAProxy, and Varnish.

Usage example: Useful for environments that require scaling by adding additional servers, also known as horizontal scaling.

Pros:

  • Makes horizontal scaling possible, that is, the resources of the environment can be increased by adding new servers to it.
  • Can protect against DDOS attacks by limiting client connections to an acceptable number and frequency.

Cons:

  • A load balancer can become a performance bottleneck if it is starved of resources or poorly configured.
  • May create additional complications that require additional effort from the administrator, for example, working with applications that require so-called “sticky sessions”.

4. HTTP Accelerator (caching reverse proxy)

An HTTP accelerator, or reverse proxy that caches HTTP requests, can be used to reduce the time required to serve content to the user by using various methods. The basic technique used with HTTP accelerator is to cache responses from a web or application server in memory, so that subsequent requests for the same content can be processed quickly and with fewer unnecessary interactions with the web or application server.

Examples of software that supports HTTP acceleration: Varnish, Squid, Nginx.

Usage example: Useful for dynamic web applications with heavy content or a large number of files that can be accessed simultaneously.

Pros:

  • Improves site performance by reducing the load on the web server processor through caching and compression, thereby increasing the number of users served.
  • Can be used as a reverse proxy load balancer.
  • Some software for caching can protect against DDOS attacks.

Cons:

  • Requires tuning to achieve best performance.
  • If the nature of user requests does not allow for effective caching, this can reduce server performance.

5. Database replication according to the Master-Slave scheme

One way to improve the performance of a database system that experiences many more read requests than write requests, such as in content management systems (CMS), is to use master-slave database replication. This scheme assumes the presence of one master and one or more slave nodes. In this case, all writes are directed to the master node, and read requests can be distributed among all nodes.

Usage example: Gives a good increase in application performance in terms of reading from the database.

Here is an example of a master-slave database replication with one slave node:

Pros:

  • Improves database read performance by distributing read requests across slave nodes.
  • Can improve write performance by using the master node exclusively for writes (so it doesn't waste time servicing read requests)

Cons:

  • A database application must have a mechanism for determining which nodes to send read and write requests to.
  • Slave node updates are asynchronous, so there is a chance that the data may not be the most recent when queried.
  • If the master node stops working, you cannot make any database updates until the problem is resolved.
  • Does not have built-in backup facilities in case of failure of the main node.

Example: Combining Concepts

You can load balance cache servers, in addition to application servers, and use database replication in a single environment. The goal of combining these methods is to gain the benefits of each approach without the added complexity.

Here's a rough diagram of what a server environment might look like:

Let's assume that the load balancer is configured to recognize static requests (such as images, CSS, JavaScript, etc.) and sends those requests to the caching servers and all other requests to the application servers.

Here's what will happen when a user submits a request for dynamic content:

  1. User requests dynamic content with http://example.com/(load balancer).
  2. The load balancer sends a request to the application server (app-backend).

If the user requests static content:

  1. The load balancer checks the cache-backend to see if the requested content is cached.
  2. If cached, then the requested content is returned to the load balancer, go to step 7. If not cached, then the caching server will forward the request to the application server through the load balancer.
  3. The load balancer will forward the request to the application server.
  4. The application server (app-backend) reads from the database and returns the requested content back to the load balancer.
  5. The load balancer forwards the response to the caching server (cache-backend).
  6. The caching server caches the received content and returns it to the load balancer.
  7. The load balancer returns the requested content to the user.

This environment has two possible points of failure (the load balancer and the database master), but provides the other reliability and performance benefits described in each point previously.

You should now have a good idea of ​​what exactly you will be using for your own application or applications. If you're working to improve your environment, remember that it's best to go iteratively to avoid unnecessary complexity.


Close