Jump to: navigation, search

Difference between revisions of "Obsolete:QueueService"

Line 66: Line 66:
 
=== Basic Asynchronous Queue ===
 
=== Basic Asynchronous Queue ===
  
Worker: GET /queue?wait=60&hide=60 (long-polling worker, request blocks)
+
* Worker: GET /queue?wait=60&hide=60 (long-polling worker, request blocks)
Client: PUT /queue (message inserted, returns unique that was created)
+
* Client: PUT /queue (message inserted, returns unique that was created)
Worker: Return from blocking GET request with new message and process it
+
* Worker: Return from blocking GET request with new message and process it
Worker: DELETE /queue/id
+
* Worker: DELETE /queue/id
  
 
=== Multi-cast Event Notifications ===
 
=== Multi-cast Event Notifications ===

Revision as of 22:50, 14 February 2011

Queue Service

This document is a proposal and plan for a queue service, it is not an official OpenStack project yet. Once there is a simple implementation to evaluate, it will be submitted the project to the OpenStack Project Oversight Committee for approval.

The reason for initiating a new project vs using an existing one is due to simplicity, modularity, and scale. Very few (if any) existing queue systems out there were built with multi-tenant cloud use cases in mind. Very few also have a simple and extensible REST API. There are possible solutions to build an AMQP based service, but AMQP brings complexity and a protocol not optimized for high latency and intermittent connectivity.

Requirements

The primary goals of the queue service are:

  • Simple - Initially it will expose a simple REST based API to make it easy to access from any language. It should not require much setup, if any, before applications can start pushing messages into it.
  • Modular API - Initially the focus will be on a simple REST API, but this will not in any way be a first-class API. It should be possible to add other protocols (AMQP, protocol buffers, Gearman, etc) for other use cases. Note that the internal service API will not always provide a 1-1 mapping with the external API, so some features with advanced protocols may be unavailable.
  • Fast - Since this will act as a building block for other services that may drive heavy throughput, performance will have a focus. This mostly comes down to implementation language and how clients and workers interact with the server to reduce network chatter.
  • Multi-tenant - Support multiple accounts for the service, and since this will also be a public service for some deployments, protect against potentially malicious users.
  • Persistent - Allow messages to optionally be persistent. For protocols that can support it, this can be an optional flag when the message is submitted. The persistent storage should also be modular so various data stores can be tested and to accommodate different deployment options.
  • Zones and locality awareness - As has been discussed on the OpenStack mailing list, locality in cloud services is an important feature. When dealing with where messages should be processed, there needs to be location awareness to process data where it exists to reduce network overhead and processing time.

Components

The queue service will consist of the following components:

  • Server - This is where messages are routed through. Clients will insert messages and workers will receive messages. Multiple servers may be run for high availability, and servers do not need to be aware of one another.
  • Proxy - This is an optional service that sits between the server and clients/workers. This allows clients and workers to connect to a single address and proxy to multiple servers. This is only required for extremely large deployments (such as a public cloud service) and may not be implemented until the second major milestone.
  • Client - An external application that inserts or updates messages in the queue.
  • Worker - An external application that reads, updates, or deletes messages in the queue. Note that the same application can be both a client and worker, the differentiation is only made based on typical behaviors, not on what they are capable of doing.
  • Queue - A queue is simply a namespace, it doesn't have attributes associated with it. Queues cannot be created or destroyed, they automatically appear to clients and workers when a message exists for the queue name, and is automatically removed when all messages for a given queue name are deleted.
  • Messages - A message consists of a unique ID, attributes, and a body. The unique ID is composed of the queue name plus a unique message ID. A server will only contain a single message for a given unique ID. If two messages are inserted with the same unique ID, the last one overwrites the first.
  • Accounts - This represents a user, application, or some other client/worker context. Every message is associated with an account, and accounts can have ACLs to control the CRUD operations available to them. An account ACL may list different permissions for various queue patterns.

Message Attributes

  • ttl=SECONDS - How long the message will exist in the queue.
  • persist=0|1 - Mark that this message should have a higher guarantee of delivery. This can be quantified in an SLA per deployment depending on the backing store. This allows for both fast/unreliable messages and slow/reliable messages.
  • hide=SECONDS - How long the message should be hidden from GET requests. This allows delayed insert of messages and "in progress" time when a worker GETs the message but has not deleted it.

The persist option is only available on insert, but the other options are available on all forms of insert, get, and update. All attributes will have tunable default values for deployments.

Operations for HTTP API

  • GET /queue - Return all messages in the queue that are not hidden in FIFO order.
  • GET /queue/id - Return the message with the given id.
  • PUT /queue - Insert a message and automatically generate a unique message id.
  • PUT /queue/id - Insert a message with the given id, overwriting a previous message with the id if one existed.
  • POST /queue - Update the attributes for all messages in the queue.
  • POST /queue/id - Update the attributes for the message with the given id.
  • DELETE /queue - Remove all messages in the queue.
  • DELETE /queue/id - Remove the message with the given id.

Optional GET parameters

  • limit=COUNT - Limit the number of returned messages. This allows a worker to grab as few or as many messages it can handle at once. For example, a worker resizing images may only grab one at a time, but a worker processing log messages may grab many for efficient batch processing.
  • wait=SECONDS - Wait the given time period for a new message if no messages can be returned immediately. This allows workers to long-poll if needed.
  • last=ID - Only return IDs after the given ID. This allows for multi-cast messages by always having a 'hide' value of 0 and not deleting messages (let the TTL delete them automatically).

Other Features

  • Allow secondary indexes on message metadata.

Milestones and Feature Priorities

Coming soon.

Examples

Basic Asynchronous Queue

  • Worker: GET /queue?wait=60&hide=60 (long-polling worker, request blocks)
  • Client: PUT /queue (message inserted, returns unique that was created)
  • Worker: Return from blocking GET request with new message and process it
  • Worker: DELETE /queue/id

Multi-cast Event Notifications

Worker1: GET /queue?wait=60 Worker2: GET /queue?wait=60 Client: Put /queue/id1?ttl=60 Worker1: Return from blocking GET request with new message Worker2: Return from blocking GET request with new message Worker1: GET /queue?wait=60&last=id1 Worker2: GET /queue?wait=60&last=id1

This allows multiple workers to read the same message, and the server will automatically remove the message once the message TTL has expired.