SlideShare a Scribd company logo
Gearman
Distributed Process Solution
Created by Google Drive Presentation.
Introduction
$ whoami
########################################################
####

Name

: Nguyen Duy Khanh

####

####

Job

: Student of HCMUS, Part-timer at PNC ####

####

My skills

: PHP, MySQL, JS

####

####

Love

: New technology

####

########################################################
$|
Problems
HEAVY WORKLOAD
function main() {
...
doSomeThing();
doSomeThingBig();
doSomeThingBigBig();
doSomeThingVeryBig();
…
return result;
}
Problems

console.log(result);
Khanh-Nguyen - Gearman - distributed process solution
Solution
Give me a job, my
workers will do it
for you.

Worker 1
Worker 2
Worker...
Worker n
Gearman
❏ GEARMAN → MANAGER
❏ Open Source.
❏ Multi-language API.
❏ Multi-threaded ( 50k jobs / second ).
❏ Ultra fast ( written in C/C++ ).
❏ No limits on message size.
❏ Failover
Installation
1.
2.

Download source code [ https://launchpad.net/gearmand ].
Compile and install from tarball.
tar xzf gearmand-X.Y.tar.gz
cd gearmand-X.Y
./configure
make
make install

3.

Starting gearman.
gearman -d
Gearman Architecture
Customer

Job Manager

Worker
How does it work ?
Client

Hey, I can send email.
Let me do it !!!

Worker Python

Worker Node.JS
Job Manager
Worker PHP
How does it work ?
Client

Worker Python
(send_email)

Worker Node.JS
Job Manager
Worker PHP
How does it work ?
Client

And I can push
notification. Let me try !!!

Worker Python

Worker Node.JS
Job Manager
Worker PHP
How does it work ?
Client

Worker Python
(send_email)

Worker Node.JS
(push_notify)
Job Manager
Worker PHP
How does it work ?
Client

Haha, I can do them all !!!

Worker Python

Worker Node.JS
Job Manager
Worker PHP
How does it work ?
Client

Worker Python
(send_email)

Worker Node.JS
(push_notify)
Job Manager
Worker PHP
(send_email, push_notify)
How does it work ?
Client

I need send an email to
abc@xyz.com , please
help me !

Worker Python
(send_email)

Worker Node.JS
(push_notify)
Job Manager
Worker PHP
(send_email, push_notify)
How does it work ?
Client

OK, Let me see. Aaah …
We have 2 workers can do
it for you. But, Worker
Python is busy, let Worker
PHP do it.

Worker Python
(send_email)

Worker Node.JS
(push_notify)
Job Manager
Worker PHP
(send_email, push_notify)
How does it work ?
Client

Hey Worker PHP, please
send an email to
abc@xyz.com

Worker Python
(send_email)

Worker Node.JS
(push_notify)
Job Manager
Worker PHP
(send_email, push_notify)
How does it work ?
Client
OK Boss, email has sent
to abc@xyz.com

Worker Python
(send_email)

Worker Node.JS
(push_notify)
Job Manager
Worker PHP
(send_email, push_notify)
How does it work ?
Client
Hi client, your email has
sent to abc@xyz.com.

Worker Python
(send_email)

Worker Node.JS
(push_notify)
Job Manager
Worker PHP
(send_email, push_notify)
Hello world !!!
Install Node.js API
$ npm install node-gearman
Install PHP API
$ pecl install gearman
Install Python API
$ pip install gearman
or
$ easy_install gearman
Hello world !!!
worker1.js
Hello world !!!
worker2.py
Hello world !!!
client.php
Hello world !!!
●

Python and C/C++ and a good choices for workers.

●

PHP, Node.js should be client than worker. [ PHP Worker often crash after
1-2 hours because memory leak ]
Use-cases
❏ Scatter/Gather
❏ Map - Reduce
❏ Asynchronous Queues
❏ Pipeline Processing
Scatter / Gather
● Perform a number of task concurrently.
○ Ex : Db Query, Image Processing, Location Search,
Full-text Search…
● Take advantage of many tier.
● Speed up your web applications.
● Tasks don’t need to be related.
Scatter / Gather
Db Query
Client

Resize Image
Search
Map / Reduce
Asynchronous Queues
● Most popular use-case.
● Do something needn’t immediate processing.
○ Ex : send emails, push notification, index data,
crawling, ...
● Allows for batch operations.
Asynchronous Queues
function tweet(msg) {
// Insert to database
db.insert(msg);
// Background tasks
gearman.push_notify();
// Return
return true;
}
Pipeline Processing
● Do related thing.
○ Ex : search engine, data analytic, ...
● Chain workers to send data to next step.
Pipeline Processing

Main
Client

Worker
Step 1

Client

Worker
Step 2

Client

Worker
Last Step

Output
Examples
GEARMAN Auto News Crawling System
Reload
Request

MongoDB

●

Manager : GEARMAN

●

Workers
“parse_rss”

Gearman Client

Webserver : Node.JS

No

Workers : Python

●

RSS
Sources

●

Web Framework : Express

●

Database : MongoDB

●

Client Script : jQuery

Have new items ?

Crawl new items

Workers
“crawling”

End
Persistent Queues
❏

By default, jobs are only stored in memory.

❏

Various contributions from community :
❏

MySQL / Drizzle

❏

PostgreSQL

❏

SQLite

❏

Tokyo Cabinet

❏

memcached

❏

Hope MongoDB (or an NOSQL DB) coming soon.
Gearman Admin GUI
●

Command Line Tool : http://gearman.info/bin/gearadmin.html

●

Gearman-Monitor [ PHP ] : https://github.com/yugene/Gearman-Monitor

●

GearmanUI [ PHP ] : http://rripado.info/gearmanui/
Khanh-Nguyen - Gearman - distributed process solution
THE
N
D

THANK YOU !!!
About Us
Author : Khanh Nguyen Duy
Find me at : admin@ndksolution.com
Presentation made for “Javascript HoChiMinh City Meetup”
You can find us at :
● http://meetup.com/JavaScript-Ho-Chi-Minh-City/
● https://www.facebook.com/JavaScriptHCMC
● https://plus.google.com/u/0/communities/116105314977285194967

More Related Content

PDF
Distributed Queue System using Gearman
PDF
Gearman: A Job Server made for Scale
KEY
Gearman
PPT
Gearman and asynchronous processing in PHP applications
PPTX
Gearman, Supervisor and PHP - Job Management with Sanity!
PDF
Queue your work
KEY
Scale like a pro with Gearman
PPT
Gearman - Job Queue
Distributed Queue System using Gearman
Gearman: A Job Server made for Scale
Gearman
Gearman and asynchronous processing in PHP applications
Gearman, Supervisor and PHP - Job Management with Sanity!
Queue your work
Scale like a pro with Gearman
Gearman - Job Queue

What's hot (20)

PPTX
Distributed Applications with Perl & Gearman
KEY
Gearman and CodeIgniter
PDF
Faster PHP apps using Queues and Workers
PDF
Madison PHP 2015 - DevOps For Small Teams
PDF
Gearman - Northeast PHP 2012
PDF
The Mysteries Of JavaScript-Fu (RailsConf Ediition)
KEY
Why I Love TorqueBox (And Why You Will Too)
PDF
I Promise You
PDF
Improve the deployment process step by step
ODP
Choosing a Web Architecture for Perl
PDF
Cucumber.js: Cuke up your JavaScript!
PPTX
Using the Command Line: Bash and WP-CLI
PDF
Ruby meetup 7_years_in_testing
PDF
A look at FastCgi & Mod_PHP architecture
PDF
Automated Web App Performance Testing Using WebDriver
PPT
Ruby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.com
PPTX
Word press workflows and gulp
PDF
Os Fitzpatrick Sussman Swp
PDF
Mad scalability: Scaling when you are not Google
PDF
Os Alrubaie
Distributed Applications with Perl & Gearman
Gearman and CodeIgniter
Faster PHP apps using Queues and Workers
Madison PHP 2015 - DevOps For Small Teams
Gearman - Northeast PHP 2012
The Mysteries Of JavaScript-Fu (RailsConf Ediition)
Why I Love TorqueBox (And Why You Will Too)
I Promise You
Improve the deployment process step by step
Choosing a Web Architecture for Perl
Cucumber.js: Cuke up your JavaScript!
Using the Command Line: Bash and WP-CLI
Ruby meetup 7_years_in_testing
A look at FastCgi & Mod_PHP architecture
Automated Web App Performance Testing Using WebDriver
Ruby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.com
Word press workflows and gulp
Os Fitzpatrick Sussman Swp
Mad scalability: Scaling when you are not Google
Os Alrubaie
Ad

Similar to Khanh-Nguyen - Gearman - distributed process solution (20)

PPTX
Qless
KEY
Intro To Django
PDF
Tips and Tricks for Automating Windows with Chef
PDF
Usability in the GeoWeb
PDF
Quest for the Perfect Workflow for McrFRED
PPT
CoffeeScript: A beginner's presentation for beginners copy
ODP
Security and why you need to review yours.
PDF
How happy they became with H2O/mruby and the future of HTTP
PDF
Lush E-Commerce Migration - Google NEXT London
PDF
High Performance Drupal
PPTX
Docker for Development
PPTX
HOW TO START (ANYTHING ABOUT CODE).pptx
PDF
The Fairy Tale of the One Command Build Script
PDF
Introduction To Apache Pig at WHUG
PDF
New Jersey Red Hat Users Group Presentation: Provisioning anywhere
PDF
JLPDevs - Optimization Tooling for Modern Web App Development
PDF
Drupalcamp performance
PDF
Cheap HPC
PDF
Node azure
ODP
2014 11 20 Drupal 7 -> 8 test migratie
Qless
Intro To Django
Tips and Tricks for Automating Windows with Chef
Usability in the GeoWeb
Quest for the Perfect Workflow for McrFRED
CoffeeScript: A beginner's presentation for beginners copy
Security and why you need to review yours.
How happy they became with H2O/mruby and the future of HTTP
Lush E-Commerce Migration - Google NEXT London
High Performance Drupal
Docker for Development
HOW TO START (ANYTHING ABOUT CODE).pptx
The Fairy Tale of the One Command Build Script
Introduction To Apache Pig at WHUG
New Jersey Red Hat Users Group Presentation: Provisioning anywhere
JLPDevs - Optimization Tooling for Modern Web App Development
Drupalcamp performance
Cheap HPC
Node azure
2014 11 20 Drupal 7 -> 8 test migratie
Ad

More from JavaScript Meetup HCMC (8)

PDF
Writing testable js [by Ted Piotrowski]
PDF
Building workflow in Javascript: Build the awesome with Gulp.
PDF
[Js hcm] Java script- Testing the awesome
PDF
Knockout js (Dennis Haney)
PDF
Debugging JavaScript (by Thomas Bindzus, Founder, Vinagility & Thanh Loc Vo, ...
PDF
3D Web Programming [Thanh Loc Vo , CTO Epsilon Mobile ]
PDF
Nicolas Embleton, Advanced Angular JS
PDF
Nicolas-Embleton - Deploying node.js with forever and nginx
Writing testable js [by Ted Piotrowski]
Building workflow in Javascript: Build the awesome with Gulp.
[Js hcm] Java script- Testing the awesome
Knockout js (Dennis Haney)
Debugging JavaScript (by Thomas Bindzus, Founder, Vinagility & Thanh Loc Vo, ...
3D Web Programming [Thanh Loc Vo , CTO Epsilon Mobile ]
Nicolas Embleton, Advanced Angular JS
Nicolas-Embleton - Deploying node.js with forever and nginx

Recently uploaded (20)

PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Electronic commerce courselecture one. Pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
cuic standard and advanced reporting.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PPT
Teaching material agriculture food technology
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Cloud computing and distributed systems.
Building Integrated photovoltaic BIPV_UPV.pdf
Approach and Philosophy of On baking technology
Review of recent advances in non-invasive hemoglobin estimation
Spectral efficient network and resource selection model in 5G networks
Agricultural_Statistics_at_a_Glance_2022_0.pdf
NewMind AI Weekly Chronicles - August'25-Week II
Per capita expenditure prediction using model stacking based on satellite ima...
Electronic commerce courselecture one. Pdf
Encapsulation_ Review paper, used for researhc scholars
MYSQL Presentation for SQL database connectivity
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Digital-Transformation-Roadmap-for-Companies.pptx
Chapter 3 Spatial Domain Image Processing.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
cuic standard and advanced reporting.pdf
Network Security Unit 5.pdf for BCA BBA.
Teaching material agriculture food technology
Advanced methodologies resolving dimensionality complications for autism neur...
Cloud computing and distributed systems.

Khanh-Nguyen - Gearman - distributed process solution

  • 1. Gearman Distributed Process Solution Created by Google Drive Presentation.
  • 2. Introduction $ whoami ######################################################## #### Name : Nguyen Duy Khanh #### #### Job : Student of HCMUS, Part-timer at PNC #### #### My skills : PHP, MySQL, JS #### #### Love : New technology #### ######################################################## $|
  • 3. Problems HEAVY WORKLOAD function main() { ... doSomeThing(); doSomeThingBig(); doSomeThingBigBig(); doSomeThingVeryBig(); … return result; }
  • 6. Solution Give me a job, my workers will do it for you. Worker 1 Worker 2 Worker... Worker n
  • 7. Gearman ❏ GEARMAN → MANAGER ❏ Open Source. ❏ Multi-language API. ❏ Multi-threaded ( 50k jobs / second ). ❏ Ultra fast ( written in C/C++ ). ❏ No limits on message size. ❏ Failover
  • 8. Installation 1. 2. Download source code [ https://launchpad.net/gearmand ]. Compile and install from tarball. tar xzf gearmand-X.Y.tar.gz cd gearmand-X.Y ./configure make make install 3. Starting gearman. gearman -d
  • 10. How does it work ? Client Hey, I can send email. Let me do it !!! Worker Python Worker Node.JS Job Manager Worker PHP
  • 11. How does it work ? Client Worker Python (send_email) Worker Node.JS Job Manager Worker PHP
  • 12. How does it work ? Client And I can push notification. Let me try !!! Worker Python Worker Node.JS Job Manager Worker PHP
  • 13. How does it work ? Client Worker Python (send_email) Worker Node.JS (push_notify) Job Manager Worker PHP
  • 14. How does it work ? Client Haha, I can do them all !!! Worker Python Worker Node.JS Job Manager Worker PHP
  • 15. How does it work ? Client Worker Python (send_email) Worker Node.JS (push_notify) Job Manager Worker PHP (send_email, push_notify)
  • 16. How does it work ? Client I need send an email to abc@xyz.com , please help me ! Worker Python (send_email) Worker Node.JS (push_notify) Job Manager Worker PHP (send_email, push_notify)
  • 17. How does it work ? Client OK, Let me see. Aaah … We have 2 workers can do it for you. But, Worker Python is busy, let Worker PHP do it. Worker Python (send_email) Worker Node.JS (push_notify) Job Manager Worker PHP (send_email, push_notify)
  • 18. How does it work ? Client Hey Worker PHP, please send an email to abc@xyz.com Worker Python (send_email) Worker Node.JS (push_notify) Job Manager Worker PHP (send_email, push_notify)
  • 19. How does it work ? Client OK Boss, email has sent to abc@xyz.com Worker Python (send_email) Worker Node.JS (push_notify) Job Manager Worker PHP (send_email, push_notify)
  • 20. How does it work ? Client Hi client, your email has sent to abc@xyz.com. Worker Python (send_email) Worker Node.JS (push_notify) Job Manager Worker PHP (send_email, push_notify)
  • 21. Hello world !!! Install Node.js API $ npm install node-gearman Install PHP API $ pecl install gearman Install Python API $ pip install gearman or $ easy_install gearman
  • 25. Hello world !!! ● Python and C/C++ and a good choices for workers. ● PHP, Node.js should be client than worker. [ PHP Worker often crash after 1-2 hours because memory leak ]
  • 26. Use-cases ❏ Scatter/Gather ❏ Map - Reduce ❏ Asynchronous Queues ❏ Pipeline Processing
  • 27. Scatter / Gather ● Perform a number of task concurrently. ○ Ex : Db Query, Image Processing, Location Search, Full-text Search… ● Take advantage of many tier. ● Speed up your web applications. ● Tasks don’t need to be related.
  • 28. Scatter / Gather Db Query Client Resize Image Search
  • 30. Asynchronous Queues ● Most popular use-case. ● Do something needn’t immediate processing. ○ Ex : send emails, push notification, index data, crawling, ... ● Allows for batch operations.
  • 31. Asynchronous Queues function tweet(msg) { // Insert to database db.insert(msg); // Background tasks gearman.push_notify(); // Return return true; }
  • 32. Pipeline Processing ● Do related thing. ○ Ex : search engine, data analytic, ... ● Chain workers to send data to next step.
  • 34. Examples GEARMAN Auto News Crawling System Reload Request MongoDB ● Manager : GEARMAN ● Workers “parse_rss” Gearman Client Webserver : Node.JS No Workers : Python ● RSS Sources ● Web Framework : Express ● Database : MongoDB ● Client Script : jQuery Have new items ? Crawl new items Workers “crawling” End
  • 35. Persistent Queues ❏ By default, jobs are only stored in memory. ❏ Various contributions from community : ❏ MySQL / Drizzle ❏ PostgreSQL ❏ SQLite ❏ Tokyo Cabinet ❏ memcached ❏ Hope MongoDB (or an NOSQL DB) coming soon.
  • 36. Gearman Admin GUI ● Command Line Tool : http://gearman.info/bin/gearadmin.html ● Gearman-Monitor [ PHP ] : https://github.com/yugene/Gearman-Monitor ● GearmanUI [ PHP ] : http://rripado.info/gearmanui/
  • 39. About Us Author : Khanh Nguyen Duy Find me at : admin@ndksolution.com Presentation made for “Javascript HoChiMinh City Meetup” You can find us at : ● http://meetup.com/JavaScript-Ho-Chi-Minh-City/ ● https://www.facebook.com/JavaScriptHCMC ● https://plus.google.com/u/0/communities/116105314977285194967