SlideShare a Scribd company logo
PostgreSQL:
meet your Queue



    / Presentation / Theo Schlossnagle



                                         1
PostgreSQL is Awesome



    •   Fast.

    •   Extensible.

    •   Tablespaces.

    •   Robust data types.

    •   Partitioning (albeit fake).

    •   Partial and functional indexes.

    •   Extremely supportive community.

    •   Extremely compliant with database standards.




                                                       2
PostgreSQL is not the “world”




     •   Inevitably, we must interact with the rest of the world.

     •   “non-SQL” components:

         •   nosql systems

         •   caching systems

         •   search systems (solr/lucene)

         •   management processes




                                                                    3
Appropiare Typicalis



     •   Enforce in the application:

         •   the application code that updates the price or description of a
             product in the products table;

         •   the application submits the updates to the search index system.

     •   The flaw:

         •   psql# UPDATE products
                      SET description =
                          REPLACE(description, ‘behaviour’, ‘behavior’);

         •   Administrative fixes like that require out-of-band dependency
             handling.




                                                                               4
A Solution


     •   Ideally, the database would notify all of these systems.

     •   The most common case I see: memcached.

         •   app: pull from memcached user::jesus@omniti.com
                  if not found:
                    select * from users where email=‘jesus@omniti.com‘
                    put row in memcached at user::jesus@omniti.com

         •   app: update users set mood=‘happy‘
                   where email=‘jesus@omniti.com‘
                  (a) purge memcached record
                  (b) get full row and replace in memcached

         •   hence: pgmemcache

     •   Problem:

         •   need a Postgres module for each remote component




                                                                         5
Enter Queueing



    •   Queueing?

        •   A generic message bus that allows PostgreSQL to communicate
            with other components in the architecture.

        •   Enter AMQP: “Advanced Message Queueing Protocol”

            •   Why not STOMP?

            •   Why not Starling?

            •   AMQP has been around the block, and the specification is quite
                complete.

            •   Almost every “real” message broker implementation supports
                AMQP




                                                                                 6
Setups: Installing



         •   svn export 
              https://labs.omniti.com/pgtreats/trunk/contrib/pg_amqp

         •   cd pg_amqp

         •   make USE_PGXS=1

         •   make install

         •   add to postgresql.conf:
             shared_preload_libraries = 'pg_amqp.so'

         •   (re)start postgres

         •   load the pg_amqp.sql file into your database.




                                                                       7
Setup: configuring your broker




      INSERT INTO amqp.broker (host,port,vhost,username,password)
          VALUES (‘localhost’,5672,NULL,‘guest’,‘guest’)
       RETURNING broker_id




                                                                    8
Setup: declaring an exchange




     •   This can often be done outside of the AMQP client

         •   using an AMQP management process
             (that is just, in fact, an AMQP client)

     •   Often, another component has already created the exchange.

     •   If you really need to do it within PostgreSQL:

         SELECT amqp.declare_exchange(broker_id,
                            exchange_name, exchange_type,
                            passive, durable, auto_delete)




                                                                      9
Usage: sending messages




    •   How do I connect?

        •   It’s implicit... you don’t need to.

    •   How do I disconnect?

        •   Broker connections are cached and live across transactions.

        •   If you want to explicitly disconnect:

            SELECT amqp.disconnect(broker_id);




                                                                          10
Usage: sending messages for real



     •   Sending messages as a part of my transaction:

         SELECT amqp.publish(broker_id, exchange, routing_key, message);

         •   This will publish the “message” over the specified “exchange” using
             the specified “routing_key,” but only on transaction commit within
             Postgres.



     •   Sending messages NOW:

         SELECT amqp.autonomous_publish(broker_id, exchange,
                                        routing_key, message);

         •   Publish the same message, but do it immediately.




                                                                                   11
A dark side: unsafe? WTF?




    •   Currently, pg_amqp uses the AMQP 0.8 specification.

    •   The AMQP 1.0 specification introduces formal 2PC.

    •   It is possible in the current implementation to have AMQP transaction
        fail when we commit it (in postgres’s commit txn hook) in a fashion
        that we cannot act on. Ouch.

    •   This only happens when the AMQP broker crashes between the last
        in-transaction publish call and the COMMIT on the database side.

    •   Once RabbitMQ supports AMQP 1.0, I’ll update the driver to use 2PC.




                                                                                12
Thank you for listening.
https://labs.omniti.com/pgtreats/trunk/contrib/pg_amqp/




                 / Presentation



                                                          13
Ad

More Related Content

What's hot (20)

Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)
Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)
Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)
James Titcumb
 
Dissecting the rabbit: RabbitMQ Internal Architecture
Dissecting the rabbit: RabbitMQ Internal ArchitectureDissecting the rabbit: RabbitMQ Internal Architecture
Dissecting the rabbit: RabbitMQ Internal Architecture
Alvaro Videla
 
Spring RabbitMQ
Spring RabbitMQSpring RabbitMQ
Spring RabbitMQ
Martin Toshev
 
Scaling applications with RabbitMQ at SunshinePHP
Scaling applications with RabbitMQ   at SunshinePHPScaling applications with RabbitMQ   at SunshinePHP
Scaling applications with RabbitMQ at SunshinePHP
Alvaro Videla
 
Troubleshooting RabbitMQ and services that use it
Troubleshooting RabbitMQ and services that use itTroubleshooting RabbitMQ and services that use it
Troubleshooting RabbitMQ and services that use it
Michael Klishin
 
Messaging with RabbitMQ and AMQP
Messaging with RabbitMQ and AMQPMessaging with RabbitMQ and AMQP
Messaging with RabbitMQ and AMQP
Eberhard Wolff
 
Apache James/Hupa & GWT
Apache James/Hupa & GWTApache James/Hupa & GWT
Apache James/Hupa & GWT
Manuel Carrasco Moñino
 
Messaging with amqp and rabbitmq
Messaging with amqp and rabbitmqMessaging with amqp and rabbitmq
Messaging with amqp and rabbitmq
Selasie Hanson
 
Apache james more than emails in the cloud
Apache james  more than emails in the cloudApache james  more than emails in the cloud
Apache james more than emails in the cloud
Ioan Eugen Stan
 
Rabbitmq, amqp Intro - Messaging Patterns
Rabbitmq, amqp Intro - Messaging PatternsRabbitmq, amqp Intro - Messaging Patterns
Rabbitmq, amqp Intro - Messaging Patterns
Javier Arias Losada
 
A Closer Look at RabbitMQ
A Closer Look at RabbitMQA Closer Look at RabbitMQ
A Closer Look at RabbitMQ
Kyumars Sheykh Esmaili
 
Lessons from managing a Pulsar cluster (Nutanix)
Lessons from managing a Pulsar cluster (Nutanix)Lessons from managing a Pulsar cluster (Nutanix)
Lessons from managing a Pulsar cluster (Nutanix)
StreamNative
 
Scaling PostgreSQL with Skytools
Scaling PostgreSQL with SkytoolsScaling PostgreSQL with Skytools
Scaling PostgreSQL with Skytools
Gavin Roy
 
What's New in Apache Pulsar 2.9- Pulsar Summit Asia 2021
What's New in Apache Pulsar 2.9- Pulsar Summit Asia 2021What's New in Apache Pulsar 2.9- Pulsar Summit Asia 2021
What's New in Apache Pulsar 2.9- Pulsar Summit Asia 2021
StreamNative
 
Modern Distributed Messaging and RPC
Modern Distributed Messaging and RPCModern Distributed Messaging and RPC
Modern Distributed Messaging and RPC
Max Alexejev
 
Apache Kafka: A high-throughput distributed messaging system @ JCConf 2014
Apache Kafka: A high-throughput distributed messaging system @ JCConf 2014Apache Kafka: A high-throughput distributed messaging system @ JCConf 2014
Apache Kafka: A high-throughput distributed messaging system @ JCConf 2014
Chen-en Lu
 
[@NaukriEngineering] Messaging Queues
[@NaukriEngineering] Messaging Queues[@NaukriEngineering] Messaging Queues
[@NaukriEngineering] Messaging Queues
Naukri.com
 
Configuration Management - Finding the tool to fit your needs
Configuration Management - Finding the tool to fit your needsConfiguration Management - Finding the tool to fit your needs
Configuration Management - Finding the tool to fit your needs
SaltStack
 
RabbitMQ vs Apache Kafka Part II Webinar
RabbitMQ vs Apache Kafka Part II WebinarRabbitMQ vs Apache Kafka Part II Webinar
RabbitMQ vs Apache Kafka Part II Webinar
Erlang Solutions
 
Using Apache Pulsar as a Modern, Scalable, High Performing JMS Platform - Pus...
Using Apache Pulsar as a Modern, Scalable, High Performing JMS Platform - Pus...Using Apache Pulsar as a Modern, Scalable, High Performing JMS Platform - Pus...
Using Apache Pulsar as a Modern, Scalable, High Performing JMS Platform - Pus...
StreamNative
 
Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)
Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)
Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)
James Titcumb
 
Dissecting the rabbit: RabbitMQ Internal Architecture
Dissecting the rabbit: RabbitMQ Internal ArchitectureDissecting the rabbit: RabbitMQ Internal Architecture
Dissecting the rabbit: RabbitMQ Internal Architecture
Alvaro Videla
 
Scaling applications with RabbitMQ at SunshinePHP
Scaling applications with RabbitMQ   at SunshinePHPScaling applications with RabbitMQ   at SunshinePHP
Scaling applications with RabbitMQ at SunshinePHP
Alvaro Videla
 
Troubleshooting RabbitMQ and services that use it
Troubleshooting RabbitMQ and services that use itTroubleshooting RabbitMQ and services that use it
Troubleshooting RabbitMQ and services that use it
Michael Klishin
 
Messaging with RabbitMQ and AMQP
Messaging with RabbitMQ and AMQPMessaging with RabbitMQ and AMQP
Messaging with RabbitMQ and AMQP
Eberhard Wolff
 
Messaging with amqp and rabbitmq
Messaging with amqp and rabbitmqMessaging with amqp and rabbitmq
Messaging with amqp and rabbitmq
Selasie Hanson
 
Apache james more than emails in the cloud
Apache james  more than emails in the cloudApache james  more than emails in the cloud
Apache james more than emails in the cloud
Ioan Eugen Stan
 
Rabbitmq, amqp Intro - Messaging Patterns
Rabbitmq, amqp Intro - Messaging PatternsRabbitmq, amqp Intro - Messaging Patterns
Rabbitmq, amqp Intro - Messaging Patterns
Javier Arias Losada
 
Lessons from managing a Pulsar cluster (Nutanix)
Lessons from managing a Pulsar cluster (Nutanix)Lessons from managing a Pulsar cluster (Nutanix)
Lessons from managing a Pulsar cluster (Nutanix)
StreamNative
 
Scaling PostgreSQL with Skytools
Scaling PostgreSQL with SkytoolsScaling PostgreSQL with Skytools
Scaling PostgreSQL with Skytools
Gavin Roy
 
What's New in Apache Pulsar 2.9- Pulsar Summit Asia 2021
What's New in Apache Pulsar 2.9- Pulsar Summit Asia 2021What's New in Apache Pulsar 2.9- Pulsar Summit Asia 2021
What's New in Apache Pulsar 2.9- Pulsar Summit Asia 2021
StreamNative
 
Modern Distributed Messaging and RPC
Modern Distributed Messaging and RPCModern Distributed Messaging and RPC
Modern Distributed Messaging and RPC
Max Alexejev
 
Apache Kafka: A high-throughput distributed messaging system @ JCConf 2014
Apache Kafka: A high-throughput distributed messaging system @ JCConf 2014Apache Kafka: A high-throughput distributed messaging system @ JCConf 2014
Apache Kafka: A high-throughput distributed messaging system @ JCConf 2014
Chen-en Lu
 
[@NaukriEngineering] Messaging Queues
[@NaukriEngineering] Messaging Queues[@NaukriEngineering] Messaging Queues
[@NaukriEngineering] Messaging Queues
Naukri.com
 
Configuration Management - Finding the tool to fit your needs
Configuration Management - Finding the tool to fit your needsConfiguration Management - Finding the tool to fit your needs
Configuration Management - Finding the tool to fit your needs
SaltStack
 
RabbitMQ vs Apache Kafka Part II Webinar
RabbitMQ vs Apache Kafka Part II WebinarRabbitMQ vs Apache Kafka Part II Webinar
RabbitMQ vs Apache Kafka Part II Webinar
Erlang Solutions
 
Using Apache Pulsar as a Modern, Scalable, High Performing JMS Platform - Pus...
Using Apache Pulsar as a Modern, Scalable, High Performing JMS Platform - Pus...Using Apache Pulsar as a Modern, Scalable, High Performing JMS Platform - Pus...
Using Apache Pulsar as a Modern, Scalable, High Performing JMS Platform - Pus...
StreamNative
 

Viewers also liked (17)

Skytools: PgQ Queues and applications
Skytools: PgQ Queues and applicationsSkytools: PgQ Queues and applications
Skytools: PgQ Queues and applications
elliando dias
 
Rabbitmq Boot System
Rabbitmq Boot SystemRabbitmq Boot System
Rabbitmq Boot System
Alvaro Videla
 
Использование очередей асинхронных сообщений с PostgreSQL (Илья Космодемьянский)
Использование очередей асинхронных сообщений с PostgreSQL (Илья Космодемьянский)Использование очередей асинхронных сообщений с PostgreSQL (Илья Космодемьянский)
Использование очередей асинхронных сообщений с PostgreSQL (Илья Космодемьянский)
Ontico
 
Pg amqp
Pg amqpPg amqp
Pg amqp
Command Prompt., Inc
 
Индексы в MSSQL: принципы работы и способы оптимизации
Индексы в MSSQL: принципы работы и способы оптимизацииИндексы в MSSQL: принципы работы и способы оптимизации
Индексы в MSSQL: принципы работы и способы оптимизации
Alexander Byndyu
 
BayLISA meetup: 8/16/12
BayLISA meetup: 8/16/12BayLISA meetup: 8/16/12
BayLISA meetup: 8/16/12
bcantrill
 
Fi fo euc 2014
Fi fo euc 2014Fi fo euc 2014
Fi fo euc 2014
Licenser
 
The Kitchen Cloud How To: Automating Joyent SmartMachines with Chef
The Kitchen Cloud How To: Automating Joyent SmartMachines with ChefThe Kitchen Cloud How To: Automating Joyent SmartMachines with Chef
The Kitchen Cloud How To: Automating Joyent SmartMachines with Chef
Chef Software, Inc.
 
Chef on SmartOS
Chef on SmartOSChef on SmartOS
Chef on SmartOS
Eric Saxby
 
SmartOS ZFS Architecture
SmartOS ZFS ArchitectureSmartOS ZFS Architecture
SmartOS ZFS Architecture
Bill Pijewski
 
Taming the rabbit
Taming the rabbitTaming the rabbit
Taming the rabbit
Alvaro Videla
 
OpenStack on SmartOS
OpenStack on SmartOSOpenStack on SmartOS
OpenStack on SmartOS
Daniele Stroppa
 
PostgreSQL в высоконагруженных проектах
PostgreSQL в высоконагруженных проектахPostgreSQL в высоконагруженных проектах
PostgreSQL в высоконагруженных проектах
Alexey Vasiliev
 
Experiences porting KVM to SmartOS
Experiences porting KVM to SmartOSExperiences porting KVM to SmartOS
Experiences porting KVM to SmartOS
bcantrill
 
Spilo, отказоустойчивый PostgreSQL кластер / Oleksii Kliukin (Zalando SE)
Spilo, отказоустойчивый PostgreSQL кластер / Oleksii Kliukin (Zalando SE)Spilo, отказоустойчивый PostgreSQL кластер / Oleksii Kliukin (Zalando SE)
Spilo, отказоустойчивый PostgreSQL кластер / Oleksii Kliukin (Zalando SE)
Ontico
 
SmartOS Primer
SmartOS PrimerSmartOS Primer
SmartOS Primer
Daniele Stroppa
 
Steve Jobs Inspirational Quotes
Steve Jobs Inspirational QuotesSteve Jobs Inspirational Quotes
Steve Jobs Inspirational Quotes
InsideView
 
Skytools: PgQ Queues and applications
Skytools: PgQ Queues and applicationsSkytools: PgQ Queues and applications
Skytools: PgQ Queues and applications
elliando dias
 
Rabbitmq Boot System
Rabbitmq Boot SystemRabbitmq Boot System
Rabbitmq Boot System
Alvaro Videla
 
Использование очередей асинхронных сообщений с PostgreSQL (Илья Космодемьянский)
Использование очередей асинхронных сообщений с PostgreSQL (Илья Космодемьянский)Использование очередей асинхронных сообщений с PostgreSQL (Илья Космодемьянский)
Использование очередей асинхронных сообщений с PostgreSQL (Илья Космодемьянский)
Ontico
 
Индексы в MSSQL: принципы работы и способы оптимизации
Индексы в MSSQL: принципы работы и способы оптимизацииИндексы в MSSQL: принципы работы и способы оптимизации
Индексы в MSSQL: принципы работы и способы оптимизации
Alexander Byndyu
 
BayLISA meetup: 8/16/12
BayLISA meetup: 8/16/12BayLISA meetup: 8/16/12
BayLISA meetup: 8/16/12
bcantrill
 
Fi fo euc 2014
Fi fo euc 2014Fi fo euc 2014
Fi fo euc 2014
Licenser
 
The Kitchen Cloud How To: Automating Joyent SmartMachines with Chef
The Kitchen Cloud How To: Automating Joyent SmartMachines with ChefThe Kitchen Cloud How To: Automating Joyent SmartMachines with Chef
The Kitchen Cloud How To: Automating Joyent SmartMachines with Chef
Chef Software, Inc.
 
Chef on SmartOS
Chef on SmartOSChef on SmartOS
Chef on SmartOS
Eric Saxby
 
SmartOS ZFS Architecture
SmartOS ZFS ArchitectureSmartOS ZFS Architecture
SmartOS ZFS Architecture
Bill Pijewski
 
PostgreSQL в высоконагруженных проектах
PostgreSQL в высоконагруженных проектахPostgreSQL в высоконагруженных проектах
PostgreSQL в высоконагруженных проектах
Alexey Vasiliev
 
Experiences porting KVM to SmartOS
Experiences porting KVM to SmartOSExperiences porting KVM to SmartOS
Experiences porting KVM to SmartOS
bcantrill
 
Spilo, отказоустойчивый PostgreSQL кластер / Oleksii Kliukin (Zalando SE)
Spilo, отказоустойчивый PostgreSQL кластер / Oleksii Kliukin (Zalando SE)Spilo, отказоустойчивый PostgreSQL кластер / Oleksii Kliukin (Zalando SE)
Spilo, отказоустойчивый PostgreSQL кластер / Oleksii Kliukin (Zalando SE)
Ontico
 
Steve Jobs Inspirational Quotes
Steve Jobs Inspirational QuotesSteve Jobs Inspirational Quotes
Steve Jobs Inspirational Quotes
InsideView
 
Ad

Similar to PostgreSQL: meet your queue (20)

Enterprise Messaging With ActiveMQ and Spring JMS
Enterprise Messaging With ActiveMQ and Spring JMSEnterprise Messaging With ActiveMQ and Spring JMS
Enterprise Messaging With ActiveMQ and Spring JMS
Bruce Snyder
 
Chef cookbooks for OpenStack HA
Chef cookbooks for OpenStack HAChef cookbooks for OpenStack HA
Chef cookbooks for OpenStack HA
Adam Spiers
 
Cooking a rabbit pie
Cooking a rabbit pieCooking a rabbit pie
Cooking a rabbit pie
Tomas Doran
 
FIWARE Tech Summit - Docker Swarm Secrets for Creating Great FIWARE Platforms
FIWARE Tech Summit - Docker Swarm Secrets for Creating Great FIWARE PlatformsFIWARE Tech Summit - Docker Swarm Secrets for Creating Great FIWARE Platforms
FIWARE Tech Summit - Docker Swarm Secrets for Creating Great FIWARE Platforms
FIWARE
 
Metasploit For Beginners
Metasploit For BeginnersMetasploit For Beginners
Metasploit For Beginners
Ramnath Shenoy
 
Docker Swarm secrets for creating great FIWARE platforms
Docker Swarm secrets for creating great FIWARE platformsDocker Swarm secrets for creating great FIWARE platforms
Docker Swarm secrets for creating great FIWARE platforms
Federico Michele Facca
 
Real time system_performance_mon
Real time system_performance_monReal time system_performance_mon
Real time system_performance_mon
Tomas Doran
 
Enabling ceph-mgr to control Ceph services via Kubernetes
Enabling ceph-mgr to control Ceph services via KubernetesEnabling ceph-mgr to control Ceph services via Kubernetes
Enabling ceph-mgr to control Ceph services via Kubernetes
mountpoint.io
 
Exactly-once Semantics in Apache Kafka
Exactly-once Semantics in Apache KafkaExactly-once Semantics in Apache Kafka
Exactly-once Semantics in Apache Kafka
confluent
 
Grabbing the PostgreSQL Elephant by the Trunk
Grabbing the PostgreSQL Elephant by the TrunkGrabbing the PostgreSQL Elephant by the Trunk
Grabbing the PostgreSQL Elephant by the Trunk
Harold Giménez
 
Corley scalability
Corley scalabilityCorley scalability
Corley scalability
Corley S.r.l.
 
Demystifying puppet
Demystifying puppetDemystifying puppet
Demystifying puppet
Ajeet Singh Raina
 
PHP Backends for Real-Time User Interaction using Apache Storm.
PHP Backends for Real-Time User Interaction using Apache Storm.PHP Backends for Real-Time User Interaction using Apache Storm.
PHP Backends for Real-Time User Interaction using Apache Storm.
DECK36
 
Consul - service discovery and others
Consul - service discovery and othersConsul - service discovery and others
Consul - service discovery and others
Walter Liu
 
EUC2015 - Load testing XMPP servers with Plain Old Erlang
EUC2015 - Load testing XMPP servers with Plain Old ErlangEUC2015 - Load testing XMPP servers with Plain Old Erlang
EUC2015 - Load testing XMPP servers with Plain Old Erlang
Paweł Pikuła
 
MongoDB at MapMyFitness
MongoDB at MapMyFitnessMongoDB at MapMyFitness
MongoDB at MapMyFitness
MapMyFitness
 
Unifying Messaging, Queueing & Light Weight Compute Using Apache Pulsar
Unifying Messaging, Queueing & Light Weight Compute Using Apache PulsarUnifying Messaging, Queueing & Light Weight Compute Using Apache Pulsar
Unifying Messaging, Queueing & Light Weight Compute Using Apache Pulsar
Karthik Ramasamy
 
Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...
Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...
Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...
Paolo Negri
 
Puppet Camp NYC 2014: Build a Modern Infrastructure in 45 min!
Puppet Camp NYC 2014: Build a Modern Infrastructure in 45 min!Puppet Camp NYC 2014: Build a Modern Infrastructure in 45 min!
Puppet Camp NYC 2014: Build a Modern Infrastructure in 45 min!
Puppet
 
Docker Swarm and Traefik 2.0
Docker Swarm and Traefik 2.0Docker Swarm and Traefik 2.0
Docker Swarm and Traefik 2.0
Jakub Hajek
 
Enterprise Messaging With ActiveMQ and Spring JMS
Enterprise Messaging With ActiveMQ and Spring JMSEnterprise Messaging With ActiveMQ and Spring JMS
Enterprise Messaging With ActiveMQ and Spring JMS
Bruce Snyder
 
Chef cookbooks for OpenStack HA
Chef cookbooks for OpenStack HAChef cookbooks for OpenStack HA
Chef cookbooks for OpenStack HA
Adam Spiers
 
Cooking a rabbit pie
Cooking a rabbit pieCooking a rabbit pie
Cooking a rabbit pie
Tomas Doran
 
FIWARE Tech Summit - Docker Swarm Secrets for Creating Great FIWARE Platforms
FIWARE Tech Summit - Docker Swarm Secrets for Creating Great FIWARE PlatformsFIWARE Tech Summit - Docker Swarm Secrets for Creating Great FIWARE Platforms
FIWARE Tech Summit - Docker Swarm Secrets for Creating Great FIWARE Platforms
FIWARE
 
Metasploit For Beginners
Metasploit For BeginnersMetasploit For Beginners
Metasploit For Beginners
Ramnath Shenoy
 
Docker Swarm secrets for creating great FIWARE platforms
Docker Swarm secrets for creating great FIWARE platformsDocker Swarm secrets for creating great FIWARE platforms
Docker Swarm secrets for creating great FIWARE platforms
Federico Michele Facca
 
Real time system_performance_mon
Real time system_performance_monReal time system_performance_mon
Real time system_performance_mon
Tomas Doran
 
Enabling ceph-mgr to control Ceph services via Kubernetes
Enabling ceph-mgr to control Ceph services via KubernetesEnabling ceph-mgr to control Ceph services via Kubernetes
Enabling ceph-mgr to control Ceph services via Kubernetes
mountpoint.io
 
Exactly-once Semantics in Apache Kafka
Exactly-once Semantics in Apache KafkaExactly-once Semantics in Apache Kafka
Exactly-once Semantics in Apache Kafka
confluent
 
Grabbing the PostgreSQL Elephant by the Trunk
Grabbing the PostgreSQL Elephant by the TrunkGrabbing the PostgreSQL Elephant by the Trunk
Grabbing the PostgreSQL Elephant by the Trunk
Harold Giménez
 
PHP Backends for Real-Time User Interaction using Apache Storm.
PHP Backends for Real-Time User Interaction using Apache Storm.PHP Backends for Real-Time User Interaction using Apache Storm.
PHP Backends for Real-Time User Interaction using Apache Storm.
DECK36
 
Consul - service discovery and others
Consul - service discovery and othersConsul - service discovery and others
Consul - service discovery and others
Walter Liu
 
EUC2015 - Load testing XMPP servers with Plain Old Erlang
EUC2015 - Load testing XMPP servers with Plain Old ErlangEUC2015 - Load testing XMPP servers with Plain Old Erlang
EUC2015 - Load testing XMPP servers with Plain Old Erlang
Paweł Pikuła
 
MongoDB at MapMyFitness
MongoDB at MapMyFitnessMongoDB at MapMyFitness
MongoDB at MapMyFitness
MapMyFitness
 
Unifying Messaging, Queueing & Light Weight Compute Using Apache Pulsar
Unifying Messaging, Queueing & Light Weight Compute Using Apache PulsarUnifying Messaging, Queueing & Light Weight Compute Using Apache Pulsar
Unifying Messaging, Queueing & Light Weight Compute Using Apache Pulsar
Karthik Ramasamy
 
Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...
Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...
Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...
Paolo Negri
 
Puppet Camp NYC 2014: Build a Modern Infrastructure in 45 min!
Puppet Camp NYC 2014: Build a Modern Infrastructure in 45 min!Puppet Camp NYC 2014: Build a Modern Infrastructure in 45 min!
Puppet Camp NYC 2014: Build a Modern Infrastructure in 45 min!
Puppet
 
Docker Swarm and Traefik 2.0
Docker Swarm and Traefik 2.0Docker Swarm and Traefik 2.0
Docker Swarm and Traefik 2.0
Jakub Hajek
 
Ad

More from Theo Schlossnagle (20)

Adding Simplicity to Complexity
Adding Simplicity to ComplexityAdding Simplicity to Complexity
Adding Simplicity to Complexity
Theo Schlossnagle
 
Put Some SRE in Your Shipped Software
Put Some SRE in Your Shipped SoftwarePut Some SRE in Your Shipped Software
Put Some SRE in Your Shipped Software
Theo Schlossnagle
 
Monitoring 101
Monitoring 101Monitoring 101
Monitoring 101
Theo Schlossnagle
 
Distributed Systems - Like It Or Not
Distributed Systems - Like It Or NotDistributed Systems - Like It Or Not
Distributed Systems - Like It Or Not
Theo Schlossnagle
 
Applying SRE techniques to micro service design
Applying SRE techniques to micro service designApplying SRE techniques to micro service design
Applying SRE techniques to micro service design
Theo Schlossnagle
 
Craftsmanship
CraftsmanshipCraftsmanship
Craftsmanship
Theo Schlossnagle
 
SRECon Coherent Performance
SRECon Coherent PerformanceSRECon Coherent Performance
SRECon Coherent Performance
Theo Schlossnagle
 
Commandments of scale
Commandments of scaleCommandments of scale
Commandments of scale
Theo Schlossnagle
 
Adaptive availability
Adaptive availabilityAdaptive availability
Adaptive availability
Theo Schlossnagle
 
Project reality
Project realityProject reality
Project reality
Theo Schlossnagle
 
Monitoring the #DevOps way
Monitoring the #DevOps wayMonitoring the #DevOps way
Monitoring the #DevOps way
Theo Schlossnagle
 
Operational Software Design
Operational Software DesignOperational Software Design
Operational Software Design
Theo Schlossnagle
 
A Coherent Discussion About Performance
A Coherent Discussion About PerformanceA Coherent Discussion About Performance
A Coherent Discussion About Performance
Theo Schlossnagle
 
The math behind big systems analysis.
The math behind big systems analysis.The math behind big systems analysis.
The math behind big systems analysis.
Theo Schlossnagle
 
Understanding Slowness
Understanding SlownessUnderstanding Slowness
Understanding Slowness
Theo Schlossnagle
 
OmniOS Motivation and Design ~ LISA 2012
OmniOS Motivation and Design ~ LISA 2012OmniOS Motivation and Design ~ LISA 2012
OmniOS Motivation and Design ~ LISA 2012
Theo Schlossnagle
 
Monitoring and observability
Monitoring and observabilityMonitoring and observability
Monitoring and observability
Theo Schlossnagle
 
Omnios and unix
Omnios and unixOmnios and unix
Omnios and unix
Theo Schlossnagle
 
Monitoring and observability
Monitoring and observabilityMonitoring and observability
Monitoring and observability
Theo Schlossnagle
 
Xtreme Deployment
Xtreme DeploymentXtreme Deployment
Xtreme Deployment
Theo Schlossnagle
 

Recently uploaded (20)

Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Mastering Advance Window Functions in SQL.pdf
Mastering Advance Window Functions in SQL.pdfMastering Advance Window Functions in SQL.pdf
Mastering Advance Window Functions in SQL.pdf
Spiral Mantra
 
Vaibhav Gupta BAML: AI work flows without Hallucinations
Vaibhav Gupta BAML: AI work flows without HallucinationsVaibhav Gupta BAML: AI work flows without Hallucinations
Vaibhav Gupta BAML: AI work flows without Hallucinations
john409870
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
TrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token ListingTrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token Listing
Trs Labs
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Mastering Advance Window Functions in SQL.pdf
Mastering Advance Window Functions in SQL.pdfMastering Advance Window Functions in SQL.pdf
Mastering Advance Window Functions in SQL.pdf
Spiral Mantra
 
Vaibhav Gupta BAML: AI work flows without Hallucinations
Vaibhav Gupta BAML: AI work flows without HallucinationsVaibhav Gupta BAML: AI work flows without Hallucinations
Vaibhav Gupta BAML: AI work flows without Hallucinations
john409870
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
TrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token ListingTrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token Listing
Trs Labs
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 

PostgreSQL: meet your queue

  • 1. PostgreSQL: meet your Queue / Presentation / Theo Schlossnagle 1
  • 2. PostgreSQL is Awesome • Fast. • Extensible. • Tablespaces. • Robust data types. • Partitioning (albeit fake). • Partial and functional indexes. • Extremely supportive community. • Extremely compliant with database standards. 2
  • 3. PostgreSQL is not the “world” • Inevitably, we must interact with the rest of the world. • “non-SQL” components: • nosql systems • caching systems • search systems (solr/lucene) • management processes 3
  • 4. Appropiare Typicalis • Enforce in the application: • the application code that updates the price or description of a product in the products table; • the application submits the updates to the search index system. • The flaw: • psql# UPDATE products SET description = REPLACE(description, ‘behaviour’, ‘behavior’); • Administrative fixes like that require out-of-band dependency handling. 4
  • 5. A Solution • Ideally, the database would notify all of these systems. • The most common case I see: memcached. • app: pull from memcached user::[email protected] if not found: select * from users where email=‘[email protected]‘ put row in memcached at user::[email protected] • app: update users set mood=‘happy‘ where email=‘[email protected]‘ (a) purge memcached record (b) get full row and replace in memcached • hence: pgmemcache • Problem: • need a Postgres module for each remote component 5
  • 6. Enter Queueing • Queueing? • A generic message bus that allows PostgreSQL to communicate with other components in the architecture. • Enter AMQP: “Advanced Message Queueing Protocol” • Why not STOMP? • Why not Starling? • AMQP has been around the block, and the specification is quite complete. • Almost every “real” message broker implementation supports AMQP 6
  • 7. Setups: Installing • svn export https://labs.omniti.com/pgtreats/trunk/contrib/pg_amqp • cd pg_amqp • make USE_PGXS=1 • make install • add to postgresql.conf: shared_preload_libraries = 'pg_amqp.so' • (re)start postgres • load the pg_amqp.sql file into your database. 7
  • 8. Setup: configuring your broker INSERT INTO amqp.broker (host,port,vhost,username,password) VALUES (‘localhost’,5672,NULL,‘guest’,‘guest’) RETURNING broker_id 8
  • 9. Setup: declaring an exchange • This can often be done outside of the AMQP client • using an AMQP management process (that is just, in fact, an AMQP client) • Often, another component has already created the exchange. • If you really need to do it within PostgreSQL: SELECT amqp.declare_exchange(broker_id, exchange_name, exchange_type, passive, durable, auto_delete) 9
  • 10. Usage: sending messages • How do I connect? • It’s implicit... you don’t need to. • How do I disconnect? • Broker connections are cached and live across transactions. • If you want to explicitly disconnect: SELECT amqp.disconnect(broker_id); 10
  • 11. Usage: sending messages for real • Sending messages as a part of my transaction: SELECT amqp.publish(broker_id, exchange, routing_key, message); • This will publish the “message” over the specified “exchange” using the specified “routing_key,” but only on transaction commit within Postgres. • Sending messages NOW: SELECT amqp.autonomous_publish(broker_id, exchange, routing_key, message); • Publish the same message, but do it immediately. 11
  • 12. A dark side: unsafe? WTF? • Currently, pg_amqp uses the AMQP 0.8 specification. • The AMQP 1.0 specification introduces formal 2PC. • It is possible in the current implementation to have AMQP transaction fail when we commit it (in postgres’s commit txn hook) in a fashion that we cannot act on. Ouch. • This only happens when the AMQP broker crashes between the last in-transaction publish call and the COMMIT on the database side. • Once RabbitMQ supports AMQP 1.0, I’ll update the driver to use 2PC. 12
  • 13. Thank you for listening. https://labs.omniti.com/pgtreats/trunk/contrib/pg_amqp/ / Presentation 13