0

My Zend_Log writers are sending data to third-party resources, like Amazon DynamoDB, for example. Such operations take time and I want to do them in background. I tried to use pcntl_fork(), but it doesn't work correctly with Apache. Do you have any other ideas of how this parallel execution of logging operations can be done in PHP and in Zend Framework? Maybe some examples?

edit: I understand that an obvious solution would be to save log messages into some files/queue and push them through later, but this is not what I'm looking for in this question.

yegor256
  • 102,010
  • 123
  • 446
  • 597
  • 1
    Put it in some local queue and sometimes send the items to the amazon – zerkms Oct 01 '12 at 11:26
  • Store the basic information in flat files and continue with your regular process. Schedule a Cronjob (for every X minutes, based on your log queue) which will process these log using Amazon services and clear the processed logs. Each cronjob will run as a separate process. – Raj Oct 01 '12 at 15:07
  • .. what are you looking for then? PHP is single-threaded and forking would still require some form of queue to process or IPC (ie. a flat file or shared memory). – Rudi Visser Oct 02 '12 at 14:24

1 Answers1

0

The right solution to this problem is to rely on syslog and Zend_Log_Writer_Syslog. Syslog decouples log clients from actual log writers (to any third-party resources). Writer to Amazon has to be configured as part of syslog server-side configuration.

yegor256
  • 102,010
  • 123
  • 446
  • 597