Join the principal engineer of Citus Cloud for a brief overview of Citus, best use cases for it, and a drill down into how it's run and managed as a hosted service on top of AWS. The orchestration of Citus is homegrown, but comes from years of experience of running millions of PostgreSQL databases on top of AWS. Even if you aren't looking to leverage Citus to help you scale out, in this session you'll gain insights applicable to running and managing your stateful services on top of AWS. Citus is a PostgreSQL extension that transforms the database into a distributed, horizontally scalable database. Companies like Cloudflare use Citus to process 40 TB per day. With Citus MX, applications can take advantage of every node in the cluster for writes and yielding near-linear write scaling. Citus MX provide up to 500,000 durable writes per second.
10. POSTGRES AND TABLES
PG Server 0
Table 0
Table 1
Table 2
PG Server 1
Table 3
Table 4
Shard 5
11. citus (coordinator node)=# d
List of relations
Schema | Name | Type | Owner
--------+---------------+-------+----------
public | cw_metrics | table | citus
public | events | table | citus
12. citus (worker node)=# d
List of relations
Schema | Name | Type | Owner
--------+---------------------+-------+----------
public | cw_metrics_102008 | table | citus
public | cw_metrics_102012 | table | citus
public | cw_metrics_102016 | table | citus
public | cw_metrics_102064 | table | citus
public | cw_metrics_102068 | table | citus
public | events_102104 | table | citus
public | events_102108 | table | citus
public | events_102112 | table | citus
public | events_102116 | table | citus
60. SEMAPHORES & CONCURRENCY
class Formation < Actor
def add_node
add_server
servers.each do |s|
s.sem.incr(:configure)
end
end
end
61. SEMAPHORES & CONCURRENCY
class Server < Actor
def work_running
if sem.pos?(:configure)
self.state = :configuring
save_changes
end
end
def work_configuring
configure_stuff
sem.decr(:configure)
self.state = :running
save_changes
end
end
67. citus=> select * from events order by created_at desc limit 2;
-[ RECORD 1 ]-
id | 9a3dfdbd-c395-40bb-8d25-45ee7c913662
name | Timeout::Error
created_at | 2016-07-28 13:18:47.289917-07
data | {"id": "5747a999-9768-429c-b13c-c7c0947dd950", "cl
-[ RECORD 2 ]-
id | ba9d6a13-0832-47fb-a849-02f1362c9019
name | Sequel::DatabaseConnectionError
created_at | 2016-07-28 12:58:40.506267-07
data | {"id": "232835ec-31a1-44d0-ae5b-edafb2cf6978", "cl
68. SELECT count(*), name, date_trunc('hour', created_at) as hour
FROM events
WHERE created_at > now()-'1 week'::interval
GROUP BY name, hour;