Uğur Atar @Metry
https://github.com/uguratar
Codefiction
http://codefiction.tech
● … optimized for web & HTTP
● … not very memory efficient
● … easy to break & follow bad practices
● … easy to learn, difficult to master
● … no good for long running processes
● A scraping job
● Heavy database ops & disk intensive ops
● Big data analysis & dealing with large amounts of data
● Image processing
● Machine learning !?!
● CURL / Multi CURL approach
● Fork child PHP processes
● Multithreading
● Messaging queue and PHP workers
Message Broker
C1
C2
Message Payload
Application
Update the APP
ACK
● Variety of message brokers and PHP clients
● Supports different patterns
● Easy to decouple components
● Stateless infrastructure for better scalability
● Isolate and address memory problems easily
● Monitor each job individually
● Figure out messaging type
● Implementing a producer
● Implementing & decoupling a consumer
● Scaling your infrastructure
P X
Q1
Q2
C1
C2
C3
Cn
Cn
Cn
Scraping, WS Call
Image P., Send Email
APP
Message Broker Consumers
● Take care of memory leaks / Handle all exceptions
● register_shutdown_function()
● Beware of disk I/O
● Monitor your processes
● Use centralized logging
● Kill your processes gracefully
?

Long running php processes

  • 2.
  • 3.
    ● … optimizedfor web & HTTP ● … not very memory efficient ● … easy to break & follow bad practices ● … easy to learn, difficult to master ● … no good for long running processes
  • 5.
    ● A scrapingjob ● Heavy database ops & disk intensive ops ● Big data analysis & dealing with large amounts of data ● Image processing ● Machine learning !?!
  • 6.
    ● CURL /Multi CURL approach ● Fork child PHP processes ● Multithreading ● Messaging queue and PHP workers
  • 7.
  • 8.
    ● Variety ofmessage brokers and PHP clients ● Supports different patterns ● Easy to decouple components ● Stateless infrastructure for better scalability ● Isolate and address memory problems easily ● Monitor each job individually
  • 9.
    ● Figure outmessaging type ● Implementing a producer ● Implementing & decoupling a consumer ● Scaling your infrastructure
  • 10.
    P X Q1 Q2 C1 C2 C3 Cn Cn Cn Scraping, WSCall Image P., Send Email APP Message Broker Consumers
  • 14.
    ● Take careof memory leaks / Handle all exceptions ● register_shutdown_function() ● Beware of disk I/O ● Monitor your processes ● Use centralized logging ● Kill your processes gracefully
  • 15.