30
Introdução a Worker

Introdução a worker

Embed Size (px)

Citation preview

Page 1: Introdução a worker

Introdução a Worker ⚙

Page 2: Introdução a worker
Page 3: Introdução a worker
Page 4: Introdução a worker
Page 5: Introdução a worker

Faça parte da comunidade que mais

cresce 🐘👊💯🆙💹

Page 6: Introdução a worker

• Dê feedback • Manifeste-se • Interaja • Faça amigos 👲👳👦👽+🍻 • Ajude!

phpsc.com.br

Page 7: Introdução a worker

sergiors.com

Page 8: Introdução a worker

Importar tabela de dados

Page 9: Introdução a worker

Enviar emails

Page 10: Introdução a worker

Reporting

Page 11: Introdução a worker

Fatal error: Allowed memory size of ….

Page 12: Introdução a worker

Worker ⚙⁉

Page 13: Introdução a worker

Um processo que fica rodando, esperando por tarefas do usuário.

Page 14: Introdução a worker

Seus workers, seus processos. É necessário ter o controle

do servidor.

Page 15: Introdução a worker

Message Queue

!=

Worker

Page 16: Introdução a worker

Job

Message Queue

Worker

Qualquer tarefa que você deseja fazer.

Responsável por gerenciar suas tarefas. Ex: Beanstalkd, RabbitMQ, Gearman…

Executa (consome) as tarefas.

Page 17: Introdução a worker

Job Message Queue Worker

Page 18: Introdução a worker

Processos que podem causar latência

• Mailing • Reporting • Web crawling

Page 19: Introdução a worker

Processos diferentes, workers diferentes⁉

Page 20: Introdução a worker

https://github.com/sergiors/worker

Page 21: Introdução a worker

Command Pattern

Page 22: Introdução a worker

interface CommandInterface { public function setContainer(\ArrayAccess $container);

public function execute(); }

Page 23: Introdução a worker

* @var CommandInterface */ protected $command;

/** * @param \ArrayAccess $container */ public function __construct(\ArrayAccess $container) { $this->container = $container; }

/** * @param CommandInterface $command */ public function setCommand(CommandInterface $command) { $this->command = $command; $this->command->setContainer($this->container); }

public function run() { $this->command->execute(); } }

Page 24: Introdução a worker

Hands on!

Page 25: Introdução a worker

max_execution_time: The default setting is 30. When running PHP from the command line the default setting is 0.

Page 26: Introdução a worker

set_time_limit(0)

😤😤😤

Page 27: Introdução a worker

Go beyond• Supervisor • Monolog

Page 28: Introdução a worker

Go beyond

• Asynchronous

Page 29: Introdução a worker

Dúvidas⁉

Page 30: Introdução a worker

🍻Obrigado!$beer = new BringMeBeerCommand(); $beer->setWho('Everyone'); $beer->execute();