SlideShare a Scribd company logo
Nemanja Krivokapić

Software Engineer @ PSTech
@NemanjaKr | LinkedIn

PHP &
Gearman
All you need to build large
scale web application
What is Gearman?
 Generic

Application Framework
 Job Server
 Client / Worker API
 Multi-platform and multi-language API
support
 Support priorities
How does it work?
Multi-server configuration
Jobs vs. Tasks
 Matter

of perspective
 Client delegates task to the server
 Job server delegates jobs to the workers
Supported platforms and
languages
 Platforms:

Unix/Windows
 Languages supported:






PHP
Java
C/C++
NodeJS, Python, Go, Lisp...
Gearman server installation
tips
 Don’t

use Ubuntu package for gearman
server (outdated and doesn’t work with
current PHP PECL extension)
 Build it from source:
https://launchpad.net/gearmand
 Run: gearmand --deamon
Server configuration
 All

config params are supplied through
command line
 Important ones:







--port=XXX (default 4730)
--deamon
--job-retries (default NO LIMIT!)
--queue-type (default builtin, not persistent)
--listen (default INADDR_ANY)

 Use

--help
PHP Gearman
implementation
Yeah – this is cool but HOW CAN I USE IT?
Little bit of shell 
 Prerequisite:

libgearman (if built from source –
already included)
 PEAR (apt-get install php-pear)
 PECL (pear install pecl)*
 pecl install gearman
 Tell PHP to use gearman client/worker API extension
( extension=gearman.so in php.ini)

* For proxy: pear config http_proxy http://
Provided classes
 GearmanClient
 GearmanTask
 GearmanWorker
 GearmanJob
 GearmanException
GearmanClient
 Used

for communication with Job Server
from your application
 Foreground jobs (doHigh, doNormal,
doLow)
 Background jobs (doHighBackground,
doBackground, doLowBackground)
 Tasks (replace do* with addTask*)
 addTask* returns GearmanTask object,
do* returns string!
GearmanWorker
 We

use it to connect our worker script to
Job Server and wait for job

 addFunction(string

$function_name
, callable $function)
 work()
 Callable provided will receive an
GearmanJob object as argument
Running tasks in parallel
 You

can stack as many tasks using
addTask method of GearmanClient.
 They will all be executed in parallel when
you call runTasks (if there’s enough
workers available)
 Notice: Using do* methods will execute
the task immediately
Client callbacks for workers
events
 When

running foreground tasks you can register
callbacks using methods of GearmanClient using
methods:







setCompleteCallback,
setCreatedCallback,
setDataCallback,
setExceptionCallback,
setFailCallback

 They

all take single argument – callable object
which will receive GearmanTask object as an
argument.
SupervisorD – keep it running
 PHP

worker script will wait for job, do it and die.
 Supervisord – Process Control System*
 apt-get install supervisor
 Create configuration file in
/etc/supervisor/supervisord.conf
 sudo service supervisor

* Project homepage: http://supervisord.org/
SupervisorD alternative
 GearmanManager
 Easier

to setup
 PHP wrapper around GearmanWorker
 https://github.com/brianlmoon/Gearman
Manager
Relevant links







PHP Examples:
http://www.php.net/manual/en/gearman.examples.
php
Gearman Job Server documentation:
http://gearman.org/documentation/
Cool tutorials to get started with Gearman on
Ubuntu:
http://blog.andyburton.co.uk/index.php/201212/compiling-gearman-with-mysql-persistent-storageon-ubuntu-12-04-precise/
http://blog.andyburton.co.uk/index.php/201212/gearman-0-41-with-mysql-persistent-storage-andphp-pecl-0-8-3-with-gearmanmanager-on-ubuntu12-04/
Questions?

The End 

More Related Content

What's hot

Background processing with Resque
Background processing with ResqueBackground processing with Resque
Background processing with ResqueNicolas Blanco
 
Wrapping java in awesomeness aka condensator
Wrapping java in awesomeness aka condensatorWrapping java in awesomeness aka condensator
Wrapping java in awesomeness aka condensatorFlowa Oy
 
Getting Started with Capistrano
Getting Started with CapistranoGetting Started with Capistrano
Getting Started with CapistranoLaunchAny
 
Simple cache architecture
Simple cache architectureSimple cache architecture
Simple cache architectureDaeMyung Kang
 
The ten commandments for an Agile Developer
The ten commandments for an Agile DeveloperThe ten commandments for an Agile Developer
The ten commandments for an Agile DeveloperSowmya Karmali
 
Communication in Python and the C10k problem
Communication in Python and the C10k problemCommunication in Python and the C10k problem
Communication in Python and the C10k problemJose Galarza
 
Async/Await: TPL & Message Pumps
Async/Await: TPL & Message Pumps Async/Await: TPL & Message Pumps
Async/Await: TPL & Message Pumps Particular Software
 
Deploying Rails Apps with Capistrano
Deploying Rails Apps with CapistranoDeploying Rails Apps with Capistrano
Deploying Rails Apps with CapistranoNyros Technologies
 
Scala Future & Promises
Scala Future & PromisesScala Future & Promises
Scala Future & PromisesKnoldus Inc.
 
Effective java item 80 and 81
Effective java   item 80 and 81Effective java   item 80 and 81
Effective java item 80 and 81Isaac Liao
 
Welcome Azure Functions 2. 0
Welcome Azure Functions 2. 0Welcome Azure Functions 2. 0
Welcome Azure Functions 2. 0Massimo Bonanni
 
Enable IPv6 on Route53 AWS ELB, docker and node App
Enable IPv6 on Route53 AWS ELB, docker and  node AppEnable IPv6 on Route53 AWS ELB, docker and  node App
Enable IPv6 on Route53 AWS ELB, docker and node AppFyllo
 
Ruby C10K: High Performance Networking - RubyKaigi '09
Ruby C10K: High Performance Networking - RubyKaigi '09Ruby C10K: High Performance Networking - RubyKaigi '09
Ruby C10K: High Performance Networking - RubyKaigi '09Ilya Grigorik
 
Capistrano, Puppet, and Chef
Capistrano, Puppet, and ChefCapistrano, Puppet, and Chef
Capistrano, Puppet, and ChefDavid Benjamin
 

What's hot (20)

Background processing with Resque
Background processing with ResqueBackground processing with Resque
Background processing with Resque
 
Wrapping java in awesomeness aka condensator
Wrapping java in awesomeness aka condensatorWrapping java in awesomeness aka condensator
Wrapping java in awesomeness aka condensator
 
ES6 ECMA2015
ES6 ECMA2015ES6 ECMA2015
ES6 ECMA2015
 
Getting Started with Capistrano
Getting Started with CapistranoGetting Started with Capistrano
Getting Started with Capistrano
 
Capistrano
CapistranoCapistrano
Capistrano
 
Simple cache architecture
Simple cache architectureSimple cache architecture
Simple cache architecture
 
Intro to MQ
Intro to MQIntro to MQ
Intro to MQ
 
Wake Up
Wake UpWake Up
Wake Up
 
Capistrano
CapistranoCapistrano
Capistrano
 
The ten commandments for an Agile Developer
The ten commandments for an Agile DeveloperThe ten commandments for an Agile Developer
The ten commandments for an Agile Developer
 
Communication in Python and the C10k problem
Communication in Python and the C10k problemCommunication in Python and the C10k problem
Communication in Python and the C10k problem
 
Async/Await: TPL & Message Pumps
Async/Await: TPL & Message Pumps Async/Await: TPL & Message Pumps
Async/Await: TPL & Message Pumps
 
Async/Await Best Practices
Async/Await Best PracticesAsync/Await Best Practices
Async/Await Best Practices
 
Deploying Rails Apps with Capistrano
Deploying Rails Apps with CapistranoDeploying Rails Apps with Capistrano
Deploying Rails Apps with Capistrano
 
Scala Future & Promises
Scala Future & PromisesScala Future & Promises
Scala Future & Promises
 
Effective java item 80 and 81
Effective java   item 80 and 81Effective java   item 80 and 81
Effective java item 80 and 81
 
Welcome Azure Functions 2. 0
Welcome Azure Functions 2. 0Welcome Azure Functions 2. 0
Welcome Azure Functions 2. 0
 
Enable IPv6 on Route53 AWS ELB, docker and node App
Enable IPv6 on Route53 AWS ELB, docker and  node AppEnable IPv6 on Route53 AWS ELB, docker and  node App
Enable IPv6 on Route53 AWS ELB, docker and node App
 
Ruby C10K: High Performance Networking - RubyKaigi '09
Ruby C10K: High Performance Networking - RubyKaigi '09Ruby C10K: High Performance Networking - RubyKaigi '09
Ruby C10K: High Performance Networking - RubyKaigi '09
 
Capistrano, Puppet, and Chef
Capistrano, Puppet, and ChefCapistrano, Puppet, and Chef
Capistrano, Puppet, and Chef
 

Viewers also liked

Gearman and CodeIgniter
Gearman and CodeIgniterGearman and CodeIgniter
Gearman and CodeIgniterErik Giberti
 
Gearman and asynchronous processing in PHP applications
Gearman and asynchronous processing in PHP applicationsGearman and asynchronous processing in PHP applications
Gearman and asynchronous processing in PHP applicationsTeamskunkworks
 
Enchanted Objects: The next wave of the web
Enchanted Objects: The next wave of the webEnchanted Objects: The next wave of the web
Enchanted Objects: The next wave of the webDavid Rose
 
Keeping it small: Getting to know the Slim micro framework
Keeping it small: Getting to know the Slim micro frameworkKeeping it small: Getting to know the Slim micro framework
Keeping it small: Getting to know the Slim micro frameworkJeremy Kendall
 
CV Vlas Ion(1)(1)
CV Vlas Ion(1)(1)CV Vlas Ion(1)(1)
CV Vlas Ion(1)(1)Vlas Ion
 
CV Sabina Serbu_ro
CV Sabina Serbu_roCV Sabina Serbu_ro
CV Sabina Serbu_roSabina Serbu
 
CV Sorina Martin europass engleza
CV Sorina Martin europass englezaCV Sorina Martin europass engleza
CV Sorina Martin europass englezaSorina Martin
 

Viewers also liked (18)

Gearman and CodeIgniter
Gearman and CodeIgniterGearman and CodeIgniter
Gearman and CodeIgniter
 
Gearman
GearmanGearman
Gearman
 
Gearman and asynchronous processing in PHP applications
Gearman and asynchronous processing in PHP applicationsGearman and asynchronous processing in PHP applications
Gearman and asynchronous processing in PHP applications
 
Enchanted Objects: The next wave of the web
Enchanted Objects: The next wave of the webEnchanted Objects: The next wave of the web
Enchanted Objects: The next wave of the web
 
Keeping it small: Getting to know the Slim micro framework
Keeping it small: Getting to know the Slim micro frameworkKeeping it small: Getting to know the Slim micro framework
Keeping it small: Getting to know the Slim micro framework
 
Mihai_Nuta
Mihai_NutaMihai_Nuta
Mihai_Nuta
 
CV Vlas Ion(1)(1)
CV Vlas Ion(1)(1)CV Vlas Ion(1)(1)
CV Vlas Ion(1)(1)
 
CV Adina Neagu.
CV Adina Neagu.CV Adina Neagu.
CV Adina Neagu.
 
CV_Bazac_Costea_Laurentiu
CV_Bazac_Costea_LaurentiuCV_Bazac_Costea_Laurentiu
CV_Bazac_Costea_Laurentiu
 
Simona Lazar
Simona LazarSimona Lazar
Simona Lazar
 
Cv grasu nicoleta_ro
Cv grasu nicoleta_roCv grasu nicoleta_ro
Cv grasu nicoleta_ro
 
CV Sabina Serbu_ro
CV Sabina Serbu_roCV Sabina Serbu_ro
CV Sabina Serbu_ro
 
Cv Oana Taban Fondator
Cv Oana Taban FondatorCv Oana Taban Fondator
Cv Oana Taban Fondator
 
CV - Dimitriu Dragoș
CV - Dimitriu DragoșCV - Dimitriu Dragoș
CV - Dimitriu Dragoș
 
Cv andreea arion
Cv andreea arionCv andreea arion
Cv andreea arion
 
CV Denisa Musa 2016 English
CV Denisa Musa 2016 EnglishCV Denisa Musa 2016 English
CV Denisa Musa 2016 English
 
CV Nicoleta Cioroaba
CV Nicoleta CioroabaCV Nicoleta Cioroaba
CV Nicoleta Cioroaba
 
CV Sorina Martin europass engleza
CV Sorina Martin europass englezaCV Sorina Martin europass engleza
CV Sorina Martin europass engleza
 

Similar to Gearman & PHP

Gearman - Job Queue
Gearman - Job QueueGearman - Job Queue
Gearman - Job QueueDiego Lewin
 
Distributed Applications with Perl & Gearman
Distributed Applications with Perl & GearmanDistributed Applications with Perl & Gearman
Distributed Applications with Perl & GearmanIssac Goldstand
 
Gearmanpresentation 110308165409-phpapp01
Gearmanpresentation 110308165409-phpapp01Gearmanpresentation 110308165409-phpapp01
Gearmanpresentation 110308165409-phpapp01longtuan
 
Zero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleZero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleStein Inge Morisbak
 
OSDC.no 2015 introduction to node.js workshop
OSDC.no 2015 introduction to node.js workshopOSDC.no 2015 introduction to node.js workshop
OSDC.no 2015 introduction to node.js workshopleffen
 
AMIMOTO: WordPress + Amazon Web Services Hands-on PARIS
AMIMOTO: WordPress + Amazon Web Services Hands-on PARISAMIMOTO: WordPress + Amazon Web Services Hands-on PARIS
AMIMOTO: WordPress + Amazon Web Services Hands-on PARISKel
 
How and why i roll my own node.js framework
How and why i roll my own node.js frameworkHow and why i roll my own node.js framework
How and why i roll my own node.js frameworkBen Lin
 
Release with confidence
Release with confidenceRelease with confidence
Release with confidenceJohn Congdon
 
Rhebok, High Performance Rack Handler / Rubykaigi 2015
Rhebok, High Performance Rack Handler / Rubykaigi 2015Rhebok, High Performance Rack Handler / Rubykaigi 2015
Rhebok, High Performance Rack Handler / Rubykaigi 2015Masahiro Nagano
 
Node js introduction
Node js introductionNode js introduction
Node js introductionAlex Su
 
Building Web Apps with Express
Building Web Apps with ExpressBuilding Web Apps with Express
Building Web Apps with ExpressAaron Stannard
 
Serverless in-action
Serverless in-actionServerless in-action
Serverless in-actionAssaf Gannon
 
Distributed Queue System using Gearman
Distributed Queue System using GearmanDistributed Queue System using Gearman
Distributed Queue System using GearmanEric Cho
 
Appium troubleshooting
Appium troubleshootingAppium troubleshooting
Appium troubleshootingadi ben aroya
 
Parse cloud code
Parse cloud codeParse cloud code
Parse cloud code維佋 唐
 
Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...
Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...
Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...Fwdays
 
Local SQLite Database with Node for beginners
Local SQLite Database with Node for beginnersLocal SQLite Database with Node for beginners
Local SQLite Database with Node for beginnersLaurence Svekis ✔
 

Similar to Gearman & PHP (20)

Gearman - Job Queue
Gearman - Job QueueGearman - Job Queue
Gearman - Job Queue
 
Distributed Applications with Perl & Gearman
Distributed Applications with Perl & GearmanDistributed Applications with Perl & Gearman
Distributed Applications with Perl & Gearman
 
Gearmanpresentation 110308165409-phpapp01
Gearmanpresentation 110308165409-phpapp01Gearmanpresentation 110308165409-phpapp01
Gearmanpresentation 110308165409-phpapp01
 
Zero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleZero Downtime Deployment with Ansible
Zero Downtime Deployment with Ansible
 
OSDC.no 2015 introduction to node.js workshop
OSDC.no 2015 introduction to node.js workshopOSDC.no 2015 introduction to node.js workshop
OSDC.no 2015 introduction to node.js workshop
 
React loadable
React loadableReact loadable
React loadable
 
AMIMOTO: WordPress + Amazon Web Services Hands-on PARIS
AMIMOTO: WordPress + Amazon Web Services Hands-on PARISAMIMOTO: WordPress + Amazon Web Services Hands-on PARIS
AMIMOTO: WordPress + Amazon Web Services Hands-on PARIS
 
How and why i roll my own node.js framework
How and why i roll my own node.js frameworkHow and why i roll my own node.js framework
How and why i roll my own node.js framework
 
Release with confidence
Release with confidenceRelease with confidence
Release with confidence
 
Rhebok, High Performance Rack Handler / Rubykaigi 2015
Rhebok, High Performance Rack Handler / Rubykaigi 2015Rhebok, High Performance Rack Handler / Rubykaigi 2015
Rhebok, High Performance Rack Handler / Rubykaigi 2015
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
 
Building Web Apps with Express
Building Web Apps with ExpressBuilding Web Apps with Express
Building Web Apps with Express
 
Serverless in-action
Serverless in-actionServerless in-action
Serverless in-action
 
Distributed Queue System using Gearman
Distributed Queue System using GearmanDistributed Queue System using Gearman
Distributed Queue System using Gearman
 
Appium troubleshooting
Appium troubleshootingAppium troubleshooting
Appium troubleshooting
 
Parse cloud code
Parse cloud codeParse cloud code
Parse cloud code
 
Node js
Node jsNode js
Node js
 
Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...
Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...
Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...
 
Red5 - PHUG Workshops
Red5 - PHUG WorkshopsRed5 - PHUG Workshops
Red5 - PHUG Workshops
 
Local SQLite Database with Node for beginners
Local SQLite Database with Node for beginnersLocal SQLite Database with Node for beginners
Local SQLite Database with Node for beginners
 

Recently uploaded

Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsVlad Stirbu
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlPeter Udo Diehl
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Product School
 
In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsExpeed Software
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Frank van Harmelen
 
IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoTAnalytics
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)Ralf Eggert
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀DianaGray10
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2DianaGray10
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...Product School
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxDavid Michel
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...Product School
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Thierry Lestable
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsPaul Groth
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
 

Recently uploaded (20)

Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT Professionals
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 

Gearman & PHP

  • 1. Nemanja Krivokapić Software Engineer @ PSTech @NemanjaKr | LinkedIn PHP & Gearman All you need to build large scale web application
  • 2. What is Gearman?  Generic Application Framework  Job Server  Client / Worker API  Multi-platform and multi-language API support  Support priorities
  • 3. How does it work?
  • 5. Jobs vs. Tasks  Matter of perspective  Client delegates task to the server  Job server delegates jobs to the workers
  • 6. Supported platforms and languages  Platforms: Unix/Windows  Languages supported:     PHP Java C/C++ NodeJS, Python, Go, Lisp...
  • 7. Gearman server installation tips  Don’t use Ubuntu package for gearman server (outdated and doesn’t work with current PHP PECL extension)  Build it from source: https://launchpad.net/gearmand  Run: gearmand --deamon
  • 8. Server configuration  All config params are supplied through command line  Important ones:      --port=XXX (default 4730) --deamon --job-retries (default NO LIMIT!) --queue-type (default builtin, not persistent) --listen (default INADDR_ANY)  Use --help
  • 9. PHP Gearman implementation Yeah – this is cool but HOW CAN I USE IT?
  • 10. Little bit of shell   Prerequisite: libgearman (if built from source – already included)  PEAR (apt-get install php-pear)  PECL (pear install pecl)*  pecl install gearman  Tell PHP to use gearman client/worker API extension ( extension=gearman.so in php.ini) * For proxy: pear config http_proxy http://
  • 11. Provided classes  GearmanClient  GearmanTask  GearmanWorker  GearmanJob  GearmanException
  • 12. GearmanClient  Used for communication with Job Server from your application  Foreground jobs (doHigh, doNormal, doLow)  Background jobs (doHighBackground, doBackground, doLowBackground)  Tasks (replace do* with addTask*)  addTask* returns GearmanTask object, do* returns string!
  • 13. GearmanWorker  We use it to connect our worker script to Job Server and wait for job  addFunction(string $function_name , callable $function)  work()  Callable provided will receive an GearmanJob object as argument
  • 14. Running tasks in parallel  You can stack as many tasks using addTask method of GearmanClient.  They will all be executed in parallel when you call runTasks (if there’s enough workers available)  Notice: Using do* methods will execute the task immediately
  • 15. Client callbacks for workers events  When running foreground tasks you can register callbacks using methods of GearmanClient using methods:      setCompleteCallback, setCreatedCallback, setDataCallback, setExceptionCallback, setFailCallback  They all take single argument – callable object which will receive GearmanTask object as an argument.
  • 16. SupervisorD – keep it running  PHP worker script will wait for job, do it and die.  Supervisord – Process Control System*  apt-get install supervisor  Create configuration file in /etc/supervisor/supervisord.conf  sudo service supervisor * Project homepage: http://supervisord.org/
  • 17. SupervisorD alternative  GearmanManager  Easier to setup  PHP wrapper around GearmanWorker  https://github.com/brianlmoon/Gearman Manager
  • 18. Relevant links     PHP Examples: http://www.php.net/manual/en/gearman.examples. php Gearman Job Server documentation: http://gearman.org/documentation/ Cool tutorials to get started with Gearman on Ubuntu: http://blog.andyburton.co.uk/index.php/201212/compiling-gearman-with-mysql-persistent-storageon-ubuntu-12-04-precise/ http://blog.andyburton.co.uk/index.php/201212/gearman-0-41-with-mysql-persistent-storage-andphp-pecl-0-8-3-with-gearmanmanager-on-ubuntu12-04/