Message Queues and Drupal
About Me
●
●
●
●

Name: Brian Altenhofel
IRC: VeggieMeat
Twitter: @BrianAltenhofel
Drupal: #550616

What I Do: Commerce, Third-party APIs, Migrations, Devops,
anything with data...
Favorite Tools: Vim, Scotch, Padron Serie 1926 No. 1 Maduro
Message Queues and Drupal
What are message queues?
Consumer

Producer
Producer

Queue

Consumer
Consumer

Producer

What are message queues?
Publisher
Publisher
Publisher

Subscriber
Queue

Subscriber
Subscriber
You already use queues.
In Drupal...
Queues are pluggable
Backends available on Drupal.org:
AWS SQS – http://drupal.org/project/aws_sqs
Beanstalkd – http://drupal.org/project/beanstalkd
Redis – http://drupal.org/project/redis
STOMP – http://drupal.org/project/stomp
(And.... still in sandbox but ready to go...)
Openstack Marconi http://drupal.org/sandbox/BrianAltenhofel/2107851
Using a Different Queue
As easy as:

●

Global:
$conf['queue_default_class'] = 'MarconiQueue';

●

Specific queue
$conf['queue_class_{queue_name}'] = 'MarconiQueue';
Queues and Drush
●

drush queue-list

●

drush queue-run [queue_name]
Code.
Code.
function my_module_create_queue() {
  $queue = DrupalQueue::get('my_queue');
  $queue­>createQueue();
}
Code.
function my_module_create_queue_item() {
  $queue = DrupalQueue::get('my_queue');
  $queue_data = array(
    'my_key' => 'my_value',
  );
  return $queue­>createItem($queue_data);
}
Code.
function my_module_count_queue_items() {
  $queue = DrupalQueue::get('my_queue');
  
  return $queue­>numberOfItems();
}
Code.
function my_module_process_queue_item() {
  $queue = DrupalQueue::get('my_queue');
  $item = $queue­>claimItem(30);
  if ($item && $item['my_key'] == 'my_value') {
    $queue­>deleteItem($item);
  }
  else {
    $queue­>releaseItem($item);
  }
}
Code.
function my_module_cron_queue_info() {
  $queues['my_queue'] = array(
    'worker callback' =>                          
      'my_module_process_queue_item',
    'time' => 60,
    // Time for cron to spend on this queue, not
    // the lease time.
  );
  return $queues;
}
It's really that simple.
Debugging
●

watchdog() is a Drupaler's best friend

●

Log everything (for both your sanity and insanity)

●

(probably want to ship these logs if you're processing a lot of items)
(if you want to get started on that):
http://www.youtube.com/watch?v=p0Av29yaBEI
Monitoring
●

Monitor queue depths with your favorite tool (Nagios, Zabbix,
Zenoss, etc.)

●

In a pinch, you can get an idea with $queue->numberOfItems().

●

Take action if queues get too deep
Any questions?
@BrianAltenhofel
IRC: VeggieMeat (MANY channels)
brian.altenhofel@vmdoh.com

More Related Content

PDF
Batch import of large RDF datasets into Semantic MediaWiki
ODP
Drupal 7 Queues
PDF
Building rednoseday.com on Drupal 8
PPTX
Using Magento 2.3 MySQL Queues
PDF
Follow the White Rabbit - Message Queues with PHP
ODP
Art Of Message Queues
PDF
Delayed operations with queues for website performance
PDF
Messaging Standards and Systems - AMQP & RabbitMQ
Batch import of large RDF datasets into Semantic MediaWiki
Drupal 7 Queues
Building rednoseday.com on Drupal 8
Using Magento 2.3 MySQL Queues
Follow the White Rabbit - Message Queues with PHP
Art Of Message Queues
Delayed operations with queues for website performance
Messaging Standards and Systems - AMQP & RabbitMQ

Similar to Message Queues and Drupal (20)

PDF
Rabbitmq an amqp message broker
PPTX
Hhm 3479 mq clustering and shared queues for high availability
PDF
Messaging Standards and Systems - AMQP & RabbitMQ
PDF
UnCon2016 - New Job Queue Framework
PDF
Adding 1.21 Gigawatts to Applications with RabbitMQ (PHPNW Dec 2014 Meetup)
ODP
The Art of Message Queues - TEKX
PDF
Do More With Message Queue
PPTX
Massaging the Pony: Message Queues and You
DOCX
White paper for High Performance Messaging App Dev with Oracle AQ
PDF
Enterprise Messaging with RabbitMQ.pdf
PDF
PHP, RabbitMQ, and You
PPTX
High powered messaging with RabbitMQ
KEY
Message queueing
PPTX
Message Queue (MQ) Testing
PPTX
Message Queue (MQ) Testing
PPTX
RabbitMq
PDF
Life in a Queue - Using Message Queue with django
PDF
Practical Message Queueing using RabbitMQ (Nomad PHP EU Dec 2014)
PDF
London JBUG - Connecting Applications Everywhere with JBoss A-MQ
PDF
Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)
Rabbitmq an amqp message broker
Hhm 3479 mq clustering and shared queues for high availability
Messaging Standards and Systems - AMQP & RabbitMQ
UnCon2016 - New Job Queue Framework
Adding 1.21 Gigawatts to Applications with RabbitMQ (PHPNW Dec 2014 Meetup)
The Art of Message Queues - TEKX
Do More With Message Queue
Massaging the Pony: Message Queues and You
White paper for High Performance Messaging App Dev with Oracle AQ
Enterprise Messaging with RabbitMQ.pdf
PHP, RabbitMQ, and You
High powered messaging with RabbitMQ
Message queueing
Message Queue (MQ) Testing
Message Queue (MQ) Testing
RabbitMq
Life in a Queue - Using Message Queue with django
Practical Message Queueing using RabbitMQ (Nomad PHP EU Dec 2014)
London JBUG - Connecting Applications Everywhere with JBoss A-MQ
Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)
Ad

Recently uploaded (20)

PDF
Abstractive summarization using multilingual text-to-text transfer transforme...
PDF
Convolutional neural network based encoder-decoder for efficient real-time ob...
PDF
sustainability-14-14877-v2.pddhzftheheeeee
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
PDF
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
PPTX
Custom Battery Pack Design Considerations for Performance and Safety
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
A review of recent deep learning applications in wood surface defect identifi...
PPTX
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
PPT
What is a Computer? Input Devices /output devices
PDF
OpenACC and Open Hackathons Monthly Highlights July 2025
PDF
Credit Without Borders: AI and Financial Inclusion in Bangladesh
PPTX
Benefits of Physical activity for teenagers.pptx
PDF
Consumable AI The What, Why & How for Small Teams.pdf
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
PPT
Geologic Time for studying geology for geologist
PPT
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
PDF
Architecture types and enterprise applications.pdf
Abstractive summarization using multilingual text-to-text transfer transforme...
Convolutional neural network based encoder-decoder for efficient real-time ob...
sustainability-14-14877-v2.pddhzftheheeeee
Taming the Chaos: How to Turn Unstructured Data into Decisions
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
Custom Battery Pack Design Considerations for Performance and Safety
1 - Historical Antecedents, Social Consideration.pdf
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
Zenith AI: Advanced Artificial Intelligence
A review of recent deep learning applications in wood surface defect identifi...
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
What is a Computer? Input Devices /output devices
OpenACC and Open Hackathons Monthly Highlights July 2025
Credit Without Borders: AI and Financial Inclusion in Bangladesh
Benefits of Physical activity for teenagers.pptx
Consumable AI The What, Why & How for Small Teams.pdf
A contest of sentiment analysis: k-nearest neighbor versus neural network
Geologic Time for studying geology for geologist
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
Architecture types and enterprise applications.pdf
Ad

Message Queues and Drupal

Editor's Notes

  • #4: Commonly used message queues include Redis – RabbitMQ – IronMQ (service) – Amazon SQS/SNS
  • #5: - a datastore for messages to be consumed – like a mailbox - used for parallel processing, ensuring that a task is performed without blocking the user experience - scalability – typically think vertical (server size) or horizontal (more servers) – queues allow you to scale time and smooth spikes... great for rate-limited APIs - decoupling
  • #6: Many configurations possible... two most common Producer/Consumer – producers create messages, consumers claim them when they begin working on them, release them on failure, delete on completion – i.e. Parallel processing Publisher/Subscriber – publishers create messages, subscribers consume them as long as they are in the queue, message eventually expires and disappears from queue – i.e. Data feeds
  • #7: - uploading videos that need to be encoded - GitHub uses queues extensively... most of the work their service does is in the background - Drupal. Several modules implement queues (i.e. Notifications, Batch API) – every time you enable a module, it gets added to a queue to check for updates
  • #11: Queue-list will list all available queues to run Queue-run will run them (but will always delete items) – advantage over cron is that cron processes can only be run 1 at a time – queue-run can be invoked as much as you want
  • #17: Note: this is only necessary if Drupal is also acting as the consumer/subscriber. This is not necessary is Drupal is just producing or publishing messages to a queue to be consumed by something else.
  • #20: Actions: Send alert with PagerDuty... spin up new workers...