-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
221 lines (212 loc) · 6.01 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Django HA</title>
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/black.css">
<!-- Theme used for syntax highlighting of code -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
</head>
<body>
<div class="reveal">
<div class="slides">
<section>
<h1>High Available Django Setup</h1>
<p>Roland van Laar<p>
<p>Entepreneur Education and IT</p>
<p><small>
twitter: <a href="https://twitter.com/@rvanlaar">@rvanlaar</a>
</small>
<small>github:
<a href="https://github.com/rvanlaar">rvanlaar</a>
</small></p>
</section>
<section>
<p>Application Demo</p>
<p>Goals</p>
<p>Challenges</p>
<p>Overview</p>
<p>BDR</p>
<p>CSYNC2</p>
<p>WebSockets</p>
<p>That one time we were down</p>
</section>
<section>
<h1>Demo: EduWorld</h1>
<p><a href="https://app.edu-world.nl/#/start">EduWorld</a></p>
</section>
<section>
<h1>Customer's Goals</h1>
<p>Not expensive</p>
<p>Always up</p>
<p>Reliable</p>
</section>
<section>
<h1>Technical Goals</h1>
<small>i.e. My Goals</small>
<p>Buildable</p>
<p>Functional</p>
<p>Maintainable</p>
</section>
<section>
<h1>Challenges</h1>
<aside class="notes">
Ask: "What do you think are challenges to building this?"
</aside>
</section>
<section>
<h1>Challenges</h1>
<p>Media Files</p>
<p>Websockets</p>
<p>Database</p>
<p>Sessions</p>
</section>
<section>
<h1>Overview</h1>
<img src="Topology.png" alt="Network Topology" />
<aside class="notes">
Used ansible, let's encrypt, Digital Ocean
</aside>
</section>
<section>
<h1>Django</h1>
<p>Mostly CRUD</p>
<p>Treebeard, DjangoRestFrameWork</p>
<p>New Django Postgres features</p>
<aside class="notes">
Text search, ArrayField
</aside>
</section>
<section>
<h1>Front End</h1>
<p>Single Page JQuery app</p>
<p>Choose a random api host for ajax requests</p>
<p>Changes api host when api is not responding</p>
<aside class="notes">
Make sure your switching logic is correct.
</aside>
</section>
<section>
<h1>Bi-directional Replication (BDR)</h1>
<p>Postgres async Multi Master</p>
<p>Awesome</p>
<p>
<a href="http://bdr-project.org/docs/stable/index.html">docs
</a>
</p>
<aside class="notes">
This takes care of the session when the sessioncookie is on the root domain.
Is fast enough.
</aside>
</section>
<section>
<h1>BDR: gotchas</h1>
<p>
Replication user
</p>
<p class="fragment">
Sequences: USING BDR, UUID
</p>
<p class="fragment">
<a href="https://github.com/2ndQuadrant/bdr/issues/140#issuecomment-174592039">Backups</a>
</p>
<aside class="notes">
Replication user: BDR examples only show two db's on one host.
</aside>
</section>
<section>
<h1>DDL: limitations</h1>
<p>Needs a lock on all nodes</p>
<p>Downtime</p>
<p>Limitations on DDL</p>
<aside class="notes">
Limitations: set sequence: use start with,
updates and alter tables
</aside>
</section>
<section>
<h1>DDL and Migrations</h1>
<pre style="width:100%"><code class="hlsql">operations = [
migrations.RunSQL(
"""
ALTER TABLE "backend_user" ADD COLUMN "voorkeuren" text;
ALTER TABLE "backend_user" ALTER COLUMN "voorkeuren" SET DEFAULT '""';
UPDATE "backend_user" SET "voorkeuren" = DEFAULT;
ALTER TABLE "backend_user" ALTER COLUMN "voorkeuren" SET NOT NULL;
ALTER TABLE "backend_user" ALTER COLUMN "voorkeuren" DROP DEFAULT;
""",
state_operations=[
migrations.AddField(
model_name='user',
name='voorkeuren',
field=jsonfield.fields.JSONField(default=''),
preserve_default=False,)])]
</code></pre>
</section>
<section>
<h1>CSYNC2</h1>
<pre><code class="hlini">group media {
host host1.example.com host2.example.com;
key /etc/csync2/csync2-media.key;
include /var/www/django/media;
auto younger;
} </code></pre>
<p>Cronjob on both hosts:
<pre><code>/usr/sbin/csync2 -xv</code></pre>
</p>
</section>
<section>
<h1>Django Code</h1>
<pre><code class="hlpython">import socket
hostname = socket.gethostname()
media_urls = {
'host1': 'https://host1.example.com/media/',
'host2': 'https://host2.example.com/media/'
}
if hostname in media_urls.keys():
MEDIA_URL = media_urls[hostname]
else:
ERROR HANDLING</code></pre>
</section>
<section>
<h1>Websockets</h1>
<p>Tornado</p>
<p>Reconnecting websockets</p>
<p>small id for initial connect</p>
<p>uuid afterwards</p>
</section>
<section>
<h1>That one time we were down</h1>
<aside class="notes">
Mandrill to Sparkpost
</aside>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.js"></script>
<script>
// More info https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
history: true,
// More info https://github.com/hakimel/reveal.js#dependencies
dependencies: [
{ src: 'plugin/markdown/marked.js' },
{ src: 'plugin/markdown/markdown.js' },
{ src: 'plugin/notes/notes.js', async: true },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }
]
});
</script>
</body>
</html>