Multitasking PHP and MySQL
How often have you developed a website that using an external program or even a separated process? This case is not a common problem for website application because you want to make it run efficiently and fast as possible, Yet you need to provide crucial functionality for end users. Then the problem arises of how to get a fast and in the other hand full featured application that can process efficiently. Using Multitasking PHP and MySQL is the answer for that problem. Gearman provides solution for Multitasking PHP and MySQL.
MultiTasking PHP and MySQL by Using Gearman
Many years ago livejournal.com was facing a same problem. Users were uploading a lot of pictures to the website that had to be processed into their respective account. One of the process is resizing functionally such as reducing the raw image size and creating thumbnails for the website to display. These pictures mostly consisted of kittens. Million Kittens picture overloading the web application in livejournal. Then Brad Fitzpatrick formulated a great idea to deal these kind of problem, which lead to Gearman invention.
Gearman comprises a client component, multi tasking the job requested by clients, and worker programs that register themself for work and then carry out those job requests. It provides a distributed application framework. Gearman capable of multi threading and is known to be able to carry out 50000 jobs per second. Some giant websites using the C version of Gearman such as Digg, Yahoo, livejournal, SixApart, Xing, and others.
Gearman Was originally written in Perl, but later rewritten in C by Eric Day because he wanted more compatibility through client API and better performance. The Gearman process is actual job server, it receive requests for jobs and then assign them. The Gearman also keeps track of available workers and busy workers. It then handles all results from workers, passing them to the client that requested the job.
The basic gearman setup consist of a client, gearman(job server), and a worker. You can see how gearman utilizing a web environment in example picture below.
Example scheme of Gearman
Installing Gearman
You can get latest Gearman source from their website http://gearman.org/download/ or http://launchpad.net/gearmand. These sites provide links to everything you need to run Gearman (Gearman MySQL UDF and the job server). To install Gearman Job Server follow these steps :
- Unpack the source tar xvzf gearmand-1.0.tar.gz
- Go to gearmand source distribution directory cd gearmand-1.0 and then ./configure
- Now build and install it using these commands make and make install
After you done following steps above. Gearmand is installed and ready to use.
To install Gearman(PECL), the steps are essentially :
12345cd gearman-0.6.*/phpize./configuremakesudo make install
Then after doing these steps make sure to specify loading the shared lib, gearman.so in /etc/php5/conf.d/gearman.ini (for Ubuntu) with this command
1extension=*gearman.so*
If you use Ubuntu, this may already be done for you. Otherwise, add this line to php.ini. Refer to your OS manual. After you done with installing part, you can now starting to Multitasking PHP and MySQL by using Gearman
You May Want to See :
- Not everybody will be able to download Windows 10 on 29 July Not everybody will be able to download Windows 10 on 29 July
- Windows 10 Sneak Peek Windows 10 Sneak Peek
- What You Can Do To Prevent Battery Loss? What You Can Do To Prevent Battery Loss?
- Forensics Analysis of SQLite Database Forensics Analysis of SQLite Database
- Encoding Decoding Data Using PHP Encoding Decoding Data Using PHP
- Integrating User Authentication Using PHP Integrating User Authentication Using PHP
- Simple Way to Connect Swift to PHP Code Simple Way to Connect Swift to PHP Code
- String Functions PHP String Functions PHP
- Enumerations in Swift Programming Enumerations in Swift Programming
- Why You Should Create Grids With PostCSS-Ant ? Why You Should Create Grids With PostCSS-Ant ?
- Objective C Class in Swift iOS Programming How To Use Objective-C Classess in iOS Swift
- Basic Operators in Python Programming Basic Operators in Python Programming
- Tips Choosing Best Suitable Hosting Company For You Tips Choosing Best Suitable Hosting Company For You
- Creating Simple UDP Server And Client to Transfer Data Using C# / VB.net Creating Simple UDP Server And Client to Transfer Data Using C# / VB.net
- Build A Progressive Web App Using Service Workers Build A Progressive Web App Using Service Workers
- Improve Website Performance Through Caching Improve Website Performance Through Caching
- Protect Your Website Against XSS Protect Your Website Against XSS
- Create Animations in Swift Programming Create Animations in Swift Programming
- Variables and Types – Python Programming Variables and Types – Python Programming
- How to Create iOS Swift “Hello World” Program How to Create iOS Swift “Hello World” Program
- Apache Rewrite Rules Guide Apache Rewrite Rules Guide
This site uses Akismet to reduce spam. Learn how your comment data is processed.