sqs.rst 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. .. _broker-sqs:
  2. ==================
  3. Using Amazon SQS
  4. ==================
  5. .. _broker-sqs-installation:
  6. Installation
  7. ============
  8. For the Amazon SQS support you have to install the `boto`_ library::
  9. $ pip install -U boto
  10. .. _boto:
  11. http://pypi.python.org/pypi/boto
  12. .. _broker-sqs-configuration:
  13. Configuration
  14. =============
  15. You have to specify SQS in the broker URL::
  16. BROKER_URL = 'sqs://ABCDEFGHIJKLMNOPQRST:ZYXK7NiynGlTogH8Nj+P9nlE73sq3@'
  17. where the URL format is::
  18. sqs://aws_access_key_id@aws_secret_access_key@
  19. remember to include the "@" at the end.
  20. The login credentials can also be set using the environment variables
  21. :envvar:`AWS_ACCESS_KEY_ID` and :envvar:`AWS_SECRET_ACCESS_KEY`,
  22. in that case the broker url may only be ``sqs://``.
  23. Options
  24. =======
  25. region
  26. ------
  27. The default region is ``us-east-1`` but you can select another region
  28. by configuring the :setting:`BROKER_TRANSPORT_OPTIONS` setting::
  29. BROKER_TRANSPORT_OPTIONS = {'region': 'eu-west-1'}
  30. .. seealso::
  31. An overview of Amazon Web Services regions can be found here:
  32. http://aws.amazon.com/about-aws/globalinfrastructure/
  33. visibility_timeout
  34. ------------------
  35. The visibility timeout defines the number of seconds to wait
  36. for the worker to acknowledge the task before the message is redelivered
  37. to another worker. Also see caveats below.
  38. This option is set via the :setting:`BROKER_TRANSPORT_OPTIONS` setting::
  39. BROKER_TRANSPORT_OPTIONS = {'visibility_timeout': 3600} # 1 hour.
  40. The default visibility timeout is 120 seconds.
  41. queue_name_prefix
  42. -----------------
  43. By default Celery will not assign any prefix to the queue names,
  44. If you have other services using SQS you can configure it do so
  45. using the :setting:`BROKER_TRANSPORT_OPTIONS` setting::
  46. BROKER_TRANSPORT_OPTIONS = {'queue_name_prefix': 'celery-'}
  47. .. _sqs-caveats:
  48. Caveats
  49. =======
  50. - If a task is not acknowledged within the ``visibility_timeout``,
  51. the task will be redelivered to another worker and executed.
  52. This causes problems with ETA/countdown/retry tasks where the
  53. time to execute exceeds the visibility timeout; in fact if that
  54. happens it will be executed again, and again in a loop.
  55. So you have to increase the visibility timeout to match
  56. the time of the longest ETA you are planning to use.
  57. Note that Celery will redeliver messages at worker shutdown,
  58. so having a long visibility timeout will only delay the redelivery
  59. of 'lost' tasks in the event of a power failure or forcefully terminated
  60. workers.
  61. Periodic tasks will not be affected by the visibility timeout,
  62. as it is a concept separate from ETA/countdown.
  63. The maximum visibility timeout supported by AWS as of this writing
  64. is 12 hours (43200 seconds)::
  65. BROKER_TRANSPORT_OPTIONS = {'visibility_timeout': 43200}
  66. - SQS does not yet support worker remote control commands.
  67. - SQS does not yet support events, and so cannot be used with
  68. :program:`celery events`, :program:`celerymon` or the Django Admin
  69. monitor.
  70. .. _sqs-results-configuration:
  71. Results
  72. -------
  73. Multiple products in the Amazon Web Services family could be a good candidate
  74. to store or publish results with, but there is no such result backend included
  75. at this point.
  76. .. warning::
  77. Do not use the ``amqp`` backend with SQS.
  78. It will create one queue for every task, and the queues will
  79. not be collected. This could cost you money that would be better
  80. spent contributing an Amazon WS result store backend back to Celery :)