Archive for the ‘PHP MySQL development’ Category

In previous parts, we have revisited some performance, scalability, and PHP tuning related issues and not in this part of PHP MySQL development series, which is broadly focusing on the scalability of web application we will try to discuss some important aspects of load balancing.

During our PHP MySQL development we create we application with massive data and tons of interactivities between the dynamic application and end users. These all definitely lead to exert loads on the server, which has to manage all requests all the time forth and back. It is good thing that we start with a single server to handle these all sorts of loads on the dispatch as well as in order to run the web application smoothly on each client.

Another important thing is that you need to scale the web application in order to manage extra traffic or some more traffic each time you come up with some fresh initiatives. Now, in such scenario, single server is not capable to manage heavy load all the time and we need to take help of multiple servers. Technically, we can’t connect multiple servers directly with the web application or can’t split them without any intermediary server with appropriate software and hardware.

This intermediary server acts as the load-balancing server and allocates traffic judiciously to the other multiple servers with different software and hardware. Here PHP is ideal web development language to do horizontal scaling. You need not to worry about the numbers of servers you add in load-balancing server. The obvious role of load-balancing server is to provide central point to manage all incoming requests and dispatching them to the appropriate server and then again redirecting the responses from the corresponding servers to the end users in a highly synchronous manner.

There are two kids of load-balancers. The first one is software load-balancers and second is hardware load-balancers. These software balancers are install on Linux bases machines in most of the cases and have their own peculiarities in terms of built in page output caching, some gzip type of compression and other many things we need in a modern server. The big fishes are Apache, Nginx and Squid like software to do effective load balancing. If you can’t afford big brands you have Perlbal like cheaper software to help you out for small to medium projects.

The second part is of hardware load balancers that have some custom built software to manage the various hardware counterparts of the load-balancing software. In present market, Citrix Netscaler and F5 BigIP are well-known versions of the hardware load-balancers and server as good security barriers or firewalls for your web application.

Today Cloud computing is serving as new dimension in the load balancing, but here you have some distinct benefits despite their software only nature. Those benefits are coming from the unique in-built mechanisms of handling load balance across the all-existing instances. Although, cloud base load-balancers are stiff means shows less flexibility, but superb in terms of easy setup and their maintenance in cost effective manners.

In short, if you need good solution for load balancing you need to monitor the ability of manipulation or making caching of the data across the servers and sort out the most appropriate solution for you.

Conclustion

We all know that most of our PHP MySQL web application development suffering from load-balancing problems when question of scaling of web application arises. Thus, finding hardware that is more suitable or software base solution is the need of the present hour. We have many software and hardware as well as Cloud based load-balancers in the market so we need to be careful in selection.

In part one, we have grasped the idea of inter relationships between performance and scalability and further explore the role of PHP to fine-tune these parameter through opcode cache. Basically, opcode cache sits in between the PHP and server machine. Since PHP recompiles code upon each request and this takes time and resources. Therefore, opcode cache remembers the first compiled version and serve that in future request without reinventing wheel again.

Apart from this, there are various opcode caches available in the market. Fortunately, Zend server has one that is in-built whilst Microsoft is providing WinCache on proprietary platform. In opensource, area has APC as a big name. However, the installation of these products during PHP MySQL programming are easy and straightforward process. By using these products, you can gain instant and considerable performance improvements hence scalability.

It is well verse that PHP is dynamic language and generating dynamic pages that any user can change at any moment. It is general perception that dynamic pages constantly or frequently changing, but in reality, most of the dynamic pages hardly exhibit any change once they are generated. For instance FAQ page or a press release which are not changing, but in background PHP is working and CPU cycles are consuming resources to keep its process.

If we PHP MySQL developers really wish to save some we need to remove the dynamic nature of such pages so we can stop the background processes and unwanted client server interactions thus lots of CPU processes. There are several ways out to do these tasks and one of them is pre-generate HTML pages from the PHP and have to serve those pages directly to the users. Here we will experience a drawback if some changes happen to those pages it will reflect on delayed schedules, not in real-time.

Another way is to approach this problem is to implement on-the-fly cache. In this sort of PHP MySQL development entire script output is captured in to the buffer in form of file system or in to the memory in form of cache or in the database like MySQL. Whenever future requests occur that script will read from the cached copy and prevent the entire dynamic reading and delivery process saving time and processing power hence lots improvement in performance and scaling. With jpcache you can manage such processes while with Smarty templates you can get done automatically.

Conclusion :-

When performance and scaling of application are concern PHP is offering some distinctive advantages being a dynamic language of modern era. We have several mechanisms to combat with this problem and opcode cache is one of them. Same the way we can improve performance by removing the dynamic nature of nearly static pages generated by PHP.