Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
1625 lines (1421 loc) · 98.3 KB
/
Copy pathindex.html
File metadata and controls
1625 lines (1421 loc) · 98.3 KB
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<!-- Swiper JS -->
<script src="https://unpkg.com/swiper/swiper-bundle.min.js"></script>
<!-- Link Swiper's CSS -->
<link
rel="stylesheet"
href="https://unpkg.com/swiper/swiper-bundle.min.css"
/>
<!-- BEGIN Info -->
<meta
name="description"
content="Jolt - an open-source framework that deploys JAMstack + Serverless applications."
/>
<meta
name="title"
property="og:title"
content="Jolt"
/>
<meta property="og:type" content="Website" />
<meta
name="image"
property="og:image"
content="images/thumb.png"
/>
<meta
name="description"
property="og:description"
content="Jolt - an open-source framework that deploys JAMstack + Serverless applications."
/>
<meta name="author" content="Jolt" />
<!-- END Info -->
<!-- BEGIN favicon -->
<link
rel="apple-touch-icon"
sizes="180x180"
href="images/favicon/apple-touch-icon.png"
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href="images/favicon/favicon-32x32.png"
/>
<link
rel="icon"
type="image/png"
sizes="16x16"
href="images/favicon/favicon-16x16.png"
/>
<link rel="manifest" href="images/favicon/site.webmanifest" />
<link
rel="mask-icon"
href="images/favicon/safari-pinned-tab.svg"
color="#5bbad5"
/>
<link rel="shortcut icon" href="images/favicon/favicon.ico" />
<meta name="msapplication-TileColor" content="#ffffff" />
<meta
name="msapplication-config"
content="images/favicon/browserconfig.xml"
/>
<meta name="theme-color" content="#ffffff" />
<!-- END favicon -->
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Jolt</title>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"
/>
<link
rel="stylesheet"
href="https://unpkg.com/@tailwindcss/typography@0.2.x/dist/typography.min.css"
/>
<link rel="stylesheet" href="stylesheets/reset.css" />
<link rel="stylesheet" href="stylesheets/style.css" />
<link rel="stylesheet" href="stylesheets/responsive.css" />
</head>
<body>
<header class="mobile-menu-closed">
<div id="header">
<a href="">
<img src="images/logo/color_logo.svg" />
</a>
<nav>
<a href="#start-here" class="selected">Start Here</a>
<a href="#case-study">Case Study</a>
<a href="#presentation">Presentation</a>
<a href="#our-team">Our Team</a>
<a
href="https://github.com/jolt-framework"
target="_blank"
class="icon"
><i class="fab fa-github"></i
></a>
</nav>
<div id="menu">
<button type="button">
<svg
id="mobile-open"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
aria-hidden="true"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M4 6h16M4 12h16M4 18h16"
/>
</svg>
<svg
id="mobile-close"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
aria-hidden="true"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M6 18L18 6M6 6l12 12"
/>
</svg>
</button>
</div>
</div>
<div id="header-buffer"></div>
<div id="mobile-menu">
<a href="#start-here" class="selected">Start Here</a>
<a href="#case-study">Case Study</a>
<a href="#presentation">Presentation</a>
<a href="#our-team">Our Team</a>
<a href="https://github.com/core-jamstack" target="_blank"
><i class="fab fa-github"></i> GitHub</a
>
</div>
</header>
<div id="start-here" class="main-section">
<div class="h-full">
<div class="static-logo-color">
<img class="jolt lg-screen" src="images/logo/color_logo.svg" />
</div>
<div class="bg-blue">
<img
class="jolt sm-screen"
src="images/logo/color_logo.svg"
/>
<p>
An open-source framework that deploys JAMstack + Serverless applications
</p>
</div>
</div>
<div class="h-full">
<div class="bg-teal static-logo-teal-light">
<h2><span>Create. </span><span>Develop. </span><span>Build. </span><span>Deploy.</span></h2>
</div>
<div class="bg-teal">
<h2 class="sm-header">Create. Develop. Build. Deploy.</h2>
<p>
Jolt allows a user to create a project, develop locally, build your static site, and deploy to AWS within minutes.
</p>
<video src="images/videos/joltprocess.mp4" autoplay style="width: 80%; "type="video/mov" controls loop></video>
</div>
</div>
</div>
<div id="sticky">
<aside id="toc">
<ul>
<li data-section="introduction">
<a href="#introduction">
<div>
<div class="bullet"><div></div></div>
<p>0. Introduction</p>
</div>
</a>
</li>
<li data-section="introduction" class="subitem">
<a href="#jolt-quickstart-guide">
<div>
<div class="bullet"><div></div></div>
<p>0.1 Jolt Quickstart Guide</p>
</div>
</a>
</li>
<li data-section="traditional-web-application-architecture">
<a href="#traditional-web-application-architecture">
<div>
<div class="bullet"><div></div></div>
<p>1. Traditional Web Application Architecture</p>
</div>
</a>
</li>
<li data-section="traditional-web-application-architecture" class="subitem">
<a href="#how-web-app-architectures-work">
<div>
<div class="bullet"><div></div></div>
<p>1.1 How Web App Architectures Work</p>
</div>
</a>
</li>
<li data-section="traditional-web-application-architecture" class="subitem">
<a href="#three-tier-architecture">
<div>
<div class="bullet"><div></div></div>
<p>1.2. The Three-Tier Architecture</p>
</div>
</a>
</li>
<li data-section="traditional-web-application-architecture" class="subitem">
<a href="#beyond-the-three-tier-architecture">
<div>
<div class="bullet"><div></div></div>
<p>1.3 Expanding Beyond the Three-Tier Architecture</p>
</div>
</a>
</li>
<li data-section="how-the-jamstack-architecture-works">
<a href="#how-the-jamstack-architecture-works">
<div>
<div class="bullet"><div></div></div>
<p>2. How the JAMstack Architecture Works</p>
</div>
</a>
</li>
<li data-section="how-the-jamstack-architecture-works" class="subitem">
<a href="#the-jamstack-architecture">
<div>
<div class="bullet"><div></div></div>
<p>2.1 The JAMstack Architecture</p>
</div>
</a>
</li>
<li data-section="how-the-jamstack-architecture-works" class="subitem">
<a href="#contrasting-jamstack-three-tier">
<div>
<div class="bullet"><div></div></div>
<p>2.2 Contrasting JAMstack with the Three-tier Architecture</p>
</div>
</a>
</li>
<li data-section="how-the-jamstack-architecture-works" class="subitem">
<a href="#advantages-of-jamstack">
<div>
<div class="bullet"><div></div></div>
<p>2.3 Advantages of the JAMstack</p>
</div>
</a>
</li>
<li data-section="how-the-jamstack-architecture-works" class="subitem">
<a href="#tradeoffs-of-jamstack">
<div>
<div class="bullet"><div></div></div>
<p>2.4 Tradeoffs of the JAMstack</p>
</div>
</a>
</li>
<li data-section="the-serverless-architecture">
<a href="#the-serverless-architecture">
<div>
<div class="bullet"><div></div></div>
<p>3. The Serverless Architecture</p>
</div>
</a>
</li>
<li data-section="the-serverless-architecture" class="subitem">
<a href="#serverless-functions">
<div>
<div class="bullet"><div></div></div>
<p>3.1 Serverless Functions</p>
</div>
</a>
</li>
<li data-section="jamstack-plus-serverless">
<a href="#jamstack-plus-serverless">
<div>
<div class="bullet"><div></div></div>
<p>4. The JAMstack + Serverless Architecture</p>
</div>
</a>
</li>
<li data-section="jamstack-plus-serverless" class="subitem">
<a href="#building-jam-serverless-from-scratch">
<div>
<div class="bullet"><div></div></div>
<p>4.1 Building JAMstack + Serverless From Scratch</p>
</div>
</a>
</li>
<li data-section="jamstack-plus-serverless" class="subitem">
<a href="#jamstack-serverless-solution">
<div>
<div class="bullet"><div></div></div>
<p>4.2 JAMstack + Serverless Solutions</p>
</div>
</a>
</li>
<li data-section="introducing-jolt">
<a href="#introducing-jolt">
<div>
<div class="bullet"><div></div></div>
<p>5. Introducing Jolt</p>
</div>
</a>
</li>
<li data-section="introducing-jolt" class="subitem">
<a href="#core-of-jolt">
<div>
<div class="bullet"><div></div></div>
<p>5.1 The Core of Jolt</p>
</div>
</a>
</li>
<li data-section="developing-and-deploying-with-jolt">
<a href="#developing-and-deploying-with-jolt">
<div>
<div class="bullet"><div></div></div>
<p>6. Developing and Deploying With Jolt</p>
</div>
</a>
</li>
<li data-section="improving-jolt">
<a href="#improving-jolt">
<div>
<div class="bullet"><div></div></div>
<p>7. Improving Jolt</p>
</div>
</a>
</li>
<li data-section="improving-jolt" class="subitem">
<a href="#relative-paths">
<div>
<div class="bullet"><div></div></div>
<p>7.1 Implementing Relative Paths for Serverless Function Requests</p>
</div>
</a>
</li>
<li data-section="improving-jolt" class="subitem">
<a href="#atomic-deployments">
<div>
<div class="bullet"><div></div></div>
<p>7.2 Implementing Atomic Deployments of Infrastructure</p>
</div>
</a>
</li>
<li data-section="improving-jolt" class="subitem">
<a href="#updating-applications">
<div>
<div class="bullet"><div></div></div>
<p>7.3 Implementing Updates to Existing Applications</p>
</div>
</a>
</li>
<li data-section="improving-jolt" class="subitem">
<a href="#rollbacks">
<div>
<div class="bullet"><div></div></div>
<p>7.4 Implementing Rollbacks</p>
</div>
</a>
</li>
<li data-section="improving-jolt" class="subitem">
<a href="#function-packaging">
<div>
<div class="bullet"><div></div></div>
<p>7.5 Packaging Function Dependencies and Environment Variables</p>
</div>
</a>
</li>
<li data-section="improving-jolt" class="subitem">
<a href="#local-testing">
<div>
<div class="bullet"><div></div></div>
<p>7.6 Implementing a Local Development Environment for Testing</p>
</div>
</a>
</li>
<li data-section="final-architecture">
<a href="#final-architecture">
<div>
<div class="bullet"><div></div></div>
<p>8 Final Architecture</p>
</div>
</a>
</li>
<li data-section="future-work">
<a href="#future-work">
<div>
<div class="bullet"><div></div></div>
<p>9. Future Work</p>
</div>
</a>
</li>
</ul>
</aside>
</div>
<div id="case-study" class="main-section">
<div id="case-study-content">
<div class="prose">
<h1>Case Study</h1>
<div id="introduction">
<h2>0. Introduction</h2>
<p>Jolt is a lightweight, open-source framework that makes it easy to develop, deploy, and maintain JAMstack applications with serverless functions. It abstracts away the complexity of provisioning and managing infrastructure, allowing the developer to focus on the business logic of their application. Jolt is targeted towards developers who are interested in the easy development, high scalability and low latency that the JAMstack model provides, but who also need a secure, scalable environment to perform computation that can’t be done on the client.</p>
<p>To get started, we’ll introduce the functionality that Jolt provides.</p>
</div>
<div id="jolt-quickstart-guide">
<h3>0.1 Jolt Quickstart Guide</h3>
<p>To get started with Jolt, run: <strong class="code-snippet">npm install -g jolt-framework</strong></p>
<p>Note: Jolt assumes that the user has <a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html">configured their AWS credentials</a> locally through the AWS CLI with the command <em class="code-snippet">aws configure</em>.</p>
<p>Here is a list of Jolt commands: (All commands should be run from the root of the application)</p>
<table>
<thead>
<tr>
<th style="text-align: center;">Command</th>
<th style="text-align: center;">Description</th>
</tr>
</thead>
<tr>
<td><em class="code-snippet">jolt init</em></td>
<td>Initialize an application for use with Jolt: Prompts the user to answer a series of questions about the application. Answers are stored in a local configuration file that Jolt references while running other commands. </td>
</tr>
<tr>
<td><em class="code-snippet">jolt dev</em></td>
<td>Spins up the user’s front end development server + Lambda development server in order to allow the full application to be run locally.</td>
</tr>
<tr>
<td><em class="code-snippet">jolt functions</em></td>
<td>Spins up the Lambda development server by itself.</td>
</tr>
<tr>
<td><em class="code-snippet">jolt deploy</em></td>
<td>Deploys the application on AWS.</td>
</tr>
<tr>
<td><em class="code-snippet">jolt update</em></td>
<td>Builds and deploys the latest version of a previously deployed application. The underlying infrastructure is reused wherever possible.</td>
</tr>
<tr>
<td><em class="code-snippet">jolt rollback</em></td>
<td>Prompts the user to select from a list of versions associated with the current application. Once a version is selected, the front end and Lambdas are reverted to that version.</td>
</tr>
<tr>
<td><em class="code-snippet">jolt destroy</em></td>
<td>Removes an application and all of its associated AWS infrastructure.</td>
</tr>
<tr>
<td><em class="code-snippet">jolt lambda [function_name]</em></td>
<td>Creates a Lambda template in the functions folder with the specified function_name.</td>
</tr>
</table>
<p>Jolt has been tested for use with React and Gatsby applications but by specifying other build commands during initialization, other frameworks can be used as well.</p>
<p>For more information on getting started with Jolt, please visit the documentation on our <a href="https://github.com/core-jamstack/Core-Full/blob/main/README.md">GitHub page</a>.</p>
<p>The following chapters will go into detail about the JAMstack + Serverless Architecture, how we built Jolt and the challenges we overcame along the way.</p>
</div>
<div id="traditional-web-application-architecture">
<h2>1. Traditional Web Application Architecture</h2>
<p>The term “web application architecture” refers to all of the software and hardware components that make up a web application as well as the interactions between those components<a href="#reference-1"><sup>1</sup></a>. Every web application architecture has two sides, the client and the server side.</p>
</div>
<div id="how-web-app-architectures-work">
<h3>1.1 How Web App Architectures Work</h3>
<p>Communication between the client and server is performed using http requests and responses. For developers, much of defining a web app architecture is about deciding what activity happens on the client-side, and what activity occurs on the server-side.</p>
<figure>
<img src="images/diagrams/Writeup/Traditional_Architecture.png" alt="Traditional Architecture">
<figcaption>A web browser (the client) makes an http request to a web server which, in this case, returns static assets such as html and images for the browser to render.</figcaption>
</figure>
</div>
<div id="three-tier-architecture">
<h3>1.2. The Three-Tier Architecture</h3>
<p>A three-tier architecture consists of three “layers” of infrastructure: a web server, an application server, and a database.</p>
<p>The web server is the outer layer in a three-tier architecture. Web servers mostly handle serving of static assets and routing of requests to other layers of the application infrastructure when needed.</p>
<p>Application servers are built to process requests that require some computation and thus can’t be handled by a web server which is optimized for delivering static content. The application server can handle dynamic processes like payment processing, inventory management, or any other business logic the application needs.</p>
<p>With the application server providing dynamic content and the web server serving up static content, we need somewhere to actually store the data associated with this content. This brings us to the final layer in a three-tier architecture, the database.</p>
<p>The database stores persistent data so that it can be retrieved by the application or web servers on demand and sent to clients.</p>
<figure>
<img src="images/diagrams/traditional-architecture.png" alt="Traditional 3 Tier Architecture">
<figcaption>The three-tier architecture</figcaption>
</figure>
<p>With this completed three-tier architecture, a developer has a back end that can store data, perform computation and serve up static and dynamic content to users.</p>
</div>
<div id="beyond-the-three-tier-architecture">
<h3>1.3 Expanding Beyond the Three-Tier Architecture</h3>
<p>As applications grow in scope and popularity, additional pieces of infrastructure may be needed. For instance:</p>
<ul>
<li>Additional web, application or database servers</li>
<li>Load balancers to distribute traffic across the additional servers</li>
<li>Caching layers</li>
</ul>
<figure>
<img src="images/diagrams/Writeup/Complex_Three_tier_architecture.png" alt="Complex Three-Tier Architecture">
<figcaption>Expanding the three-tier architecture with a load balancer, cache, and additional web, application, and database servers.</figcaption>
</figure>
<p>Implementing more complex architectures allows developers to have more control over their application. However, the additional complexity results in:</p>
<ul>
<li>Increased difficulty of developing and maintaining the application</li>
<li>Increased time and financial costs associated with provisioning and managing the additional infrastructure</li>
</ul>
<p>New architectures have emerged that help to abstract away the complexity and cost of building and maintaining web applications. One such architecture is the JAMstack architecture.</p>
</div>
<div id="how-the-jamstack-architecture-works">
<h2>2. How the JAMstack Architecture Works</h2>
<figure>
<blockquote>"A modern web development architecture based on client-side JavaScript, reusable APIs, and prebuilt Markup."</blockquote>
<figcaption>- Mathias Biilmann, CEO, Founder of Netlify<a href="#reference-2"><sup>2</sup></a></figcaption>
</figure>
<p>JAMstack as a term was popularized by Chris Bach and Matthias Biilmann of Netlify. The above quote by Biilmann nicely summarizes the 3 pillars of the JAMstack architecture: JavaScript, APIs and Markup. Let’s break each of those down.</p>
</div>
<div id="jamstack-markup">
<h4>Markup</h4>
<p>In a three-tier architecture, servers usually perform just in time rendering. This means that content is generated when it is requested by a client. By generating content when it is requested, sites can provide a dynamic experience with personalized or context dependent content. However, the tradeoff with this approach is that the process of generating content for each request costs extra time and memory.</p>
<p>Instead of paying this cost with each request, the JAMstack approach relies on ahead of time rendering. This process involves pre-building pages which is typically done using a static site generator such as Hugo or Gatsby.</p>
<figure>
<img src="images/diagrams/Writeup/Pre_Building_Content.png" alt="Prebuilding Content">
<figcaption>The typical flow of a static site generation process wherein the website content is assembled into static HTML pages, uploaded to a CDN, and then accessed by the user.</figcaption>
</figure>
<p>This process bundles the application code into a collection of static HTML files. While this can take a while, after it’s been done once, the resulting collection of static files is ready to be served up and rendered immediately on the client. Phil Hawksworth, Director of Developer Experience at Netlify refers to this as “Doing the work now so your servers don’t have to<a href="#reference-3"><sup>3</sup></a>”.</p>
<p>Contrast this with the three-tier architecture where pages are re-built for every request, and it becomes clear that an approach of pre-rendering content will lead to much faster page load times in the long run.</p>
<p>After the content has been pre-built, it is cached on globally distributed CDN (Content Delivery Network) servers. Then, when a page is requested, the CDN server nearest to the client can send the requested page back with minimal latency. The use of a CDN for serving static content can eliminate the need for running a web server.</p>
</div>
<div id="jamstack-apis">
<h4>APIs</h4>
<p>The next piece of the JAMstack centers around the idea that most of the work traditionally done by the application server and database server layers can be performed by 3rd party services. The job of handling things like search, authentication or payment processing can be outsourced to domain experts who provide reliable, fully featured solutions that can be easily plugged into an application without the cost and complexity of building your own.</p>
<figure>
<img src="images/diagrams/Writeup/3rd_party_APIs.png" alt="Third-Party APIs">
<figcaption>Popular 3rd Party APIs</figcaption>
</figure>
<p>By using 3rd party APIs, complex computation and even data persistence can be handled without the need for database and application servers.</p>
</div>
<div id="jamstack-javascript">
<h4>JavaScript</h4>
<p>Client-side JavaScript is used to retrieve and render the kind of dynamic content that would traditionally have been handled by a backend language like Node, Python, Ruby, etc. The browser uses JavaScript to make client-side calls to 3rd party APIs and then to perform DOM manipulation to update the view on the client side as needed.</p>
</div>
<div id="the-jamstack-architecture">
<h3>2.1 The JAMstack Architecture</h3>
<figure>
<img src="images/diagrams/Writeup/JAMstack_Architecture.png" alt="JAMstack Architecture Diagram">
<figcaption>The JAMstack architecture: <strong>J</strong>avaScript in the browser, 3rd party <strong>A</strong>PI calls, <strong>M</strong>arkup from a CDN</figcaption>
</figure>
<p>An application built with a JAMstack architecture uses client-side JavaScript to make API calls and perform DOM manipulations. 3rd APIs handle processes like search, authentication, or data persistence. Finally, Markup is cached and served from a CDN to provide fast, scalable content to clients.</p>
</div>
<div id="contrasting-jamstack-three-tier">
<h3>2.2 Contrasting JAMstack with the Three-tier Architecture</h3>
<figure>
<img src="images/diagrams/Writeup/JAMstack_vs_Three_tier.png" alt="JAMStack versus Three-Tier Diagram">
<figcaption>Contrasting the Three-tier architecture with the JAMstack architecture
.</figcaption>
</figure>
<p>By viewing the JAMstack architecture alongside the three-tier architecture, it’s easy to see how they differ. With JAMstack, the serving of static content typically handled by the web server is now handled by a CDN. The business logic and persistent storage that would traditionally have been handled by a database and application server are now all abstracted away into 3rd party APIs that can perform any computation or data persistence that the application needs.</p>
</div>
<div id="advantages-of-jamstack">
<h3>2.3 Advantages of the JAMstack</h3>
<p>Beyond the simpler developer experience of not needing to build and manage servers, using the JAMstack has several major benefits<a href="#reference-4"><sup>4</sup></a>:</p>
<ol class="indented">
<li>
<h4>Performance</h4>
<p>By pre-building pages and using a CDN to cache and serve all static content, response times are faster because the page rendering that would have occurred at response time has already been completed by a static site generator.</p>
</li>
<li>
<h4>Security</h4>
<p>With no backend servers to manage, the surface area of the application is much smaller. With fewer pieces of infrastructure, the number of potential security risks is greatly reduced.</p>
</li>
<li>
<h4>Scalability</h4>
<p>A JAMstack architecture eliminates the need for manually adding and removing servers in order to scale your application, as is often required with a three-tier architecture. Because application traffic is handled by CDN servers which are managed by a cloud provider, scalability comes built in, as the cloud provider takes care of fluctuations in traffic to your application and only bills you for what you use.</p>
</li>
</ol>
<p>While there are plenty of advantages to the JAMstack approach, it’s important to be aware that it’s not a fit for every use case and tradeoffs are made when using it.</p>
</div>
<div id="tradeoffs-of-jamstack">
<h3>2.4 Tradeoffs of the JAMstack</h3>
<p>There are two main tradeoffs that come with a JAMstack Architecture: long build times and the lack of custom compute.</p>
<ol class="indented">
<li>
<h4>Long Build Times</h4>
<p>Depending on the size of the application, generating static pages with a static site generator such as Hugo or Gatsby can take anywhere from minutes to hours<a href="#reference-5"><sup>5</sup></a>.
For sites that receive constant updates, like a news site, the need to frequently rebuild static pages would be a burden that could make the JAMstack approach infeasible.
</p>
</li>
<li>
<h4>Lack of Custom Compute</h4>
<p>There are some cases where computation needs to be done that can’t be executed in the browser and for which no 3rd party API provides a complete solution.</p>
<p>In these cases, a backend server could be spun up, however doing so reintroduces some of the architectural complexity that the JAMstack architecture tries to abstract away.</p>
</li>
</ol>
<p>A way of performing secure computation is needed that doesn’t require spinning up and managing a server. One way to deal with this is by implementing a serverless architecture.</p>
</div>
<div id="the-serverless-architecture">
<h2>3. The Serverless Architecture</h2>
<p>The term “serverless” architecture refers to a cloud computing model where the servers are entirely managed by a 3rd party. In essence, the developer writes the business logic of their application and a cloud provider takes care of the provisioning and management of servers. Most often the term is used to refer to serverless functions, or Function as a Service (FaaS).</p>
</div>
<div id="serverless-functions">
<h3>3.1 Serverless Functions</h3>
<p>Amazon Web Services describes serverless functions as <q>"A compute service that lets you run code without provisioning or managing servers... or managing runtimes."</q><a href="#reference-6"><sup>6</sup></a></p>
<p>Serverless functions allow developers to work at a level of abstraction where they only need to select a runtime and write the code needed to achieve the desired functionality. After that, the code is given to a FaaS provider who will handle starting the functions (and stopping them when not in use), scaling them as traffic increases and decreases, and managing all of the underlying infrastructure.</p>
<figure>
<div class="swiper-container scalable-serverless-functions">
<div class="swiper-wrapper">
<div class="swiper-slide"><img src="images/diagrams/Writeup/Gifs/client 1.png"/></div>
<div class="swiper-slide"><img src="images/diagrams/Writeup/Gifs/client 2.png"/></div>
<div class="swiper-slide"><img src="images/diagrams/Writeup/Gifs/client 3.png"/></div>
</div>
</div>
<script>
var swiper = new Swiper(".scalable-serverless-functions", {
observer: true,
observeParents: true,
autoplay: {
delay: 1500,
}
});
</script>
<figcaption>As more requests are made, serverless functions easily scale up or down to meet demand.</figcaption>
</figure>
<p>There are several technical limitations to be aware of when evaluating whether or not serverless functions are good fit for a given use case.</p>
<ol class="indented">
<li>
<h4>Execution Time Limits</h4>
<p>Serverless functions are generally designed for shorter computation tasks. Maximum execution time limits range from about 5 to 15 minutes.</p>
</li>
<li>
<h4>Cold Starts</h4>
<p>When a function has not been used for at least 5-10 minutes, a delay called a cold start occurs because the function needs to be spun up again. Cold starts result in additional latency and must be factored into application design.</p>
</li>
</ol>
</div>
<div id="jamstack-plus-serverless">
<h2>4 The JAMstack + Serverless Architecture</h2>
<p>Serverless functions provide a solution for the lack of custom compute inherent in the JAMstack architecture and the combination of JAMstack and serverless is becoming increasingly popular. Ryan Coleman, VP of Engineering at Stackery, a company focused on the design and deployment of serverless web applications said: <q>“Serverless + JAMstack is where web app architectures are going<a href="#reference-7"><sup>7</sup></a>.”</q></p>
<p>To illustrate when how the JAMstack + serverless combination can be useful, we'll take a look at a common use case: Dealing with secret API keys when interacting with a 3rd party API like Stripe<a href="#reference-8"><sup>8</sup></a>.</p>
<p>When a user visits an e-commerce site that uses Stripe to process payments, the Stripe front-end client can be used to collect details related to billing. However, in order to checkout, the Stripe backend client is used, which requires an API key. Since this is a secret key that can’t be sent directly to the client for security reasons, a secure computing environment is needed to store the key and interface with Stripe’s API.</p>
<p>Serverless functions provide a way of securely interacting with the Stripe backend API.</p>
<figure>
<img src="images/diagrams/Writeup/JAMstack_Serverless_architecture_Stripe.png" alt="Stripe using Jamstack plus Serverless architecture">
<figcaption>The Stripe client API is used to collect payment details which are sent to a serverless function that interfaces with Stripe directly using a secret API key.</figcaption>
</figure>
<p>In a JAMstack + serverless application, the payment information can be sent from the client to a serverless function that holds the Stripe API key. The function can then securely contact Stripe on the client’s behalf, await a response and then send the confirmation back to the client. This approach allows for secure processing of payments without the need to provision and manage complicated back end servers.</p>
<p>By adding serverless functions to the JAMstack architecture, applications regain the ability to perform custom computation that was lost by removing backend servers from the architecture.</p>
</div>
<div id="building-jam-serverless-from-scratch">
<h3>4.1 Building JAMstack + Serverless From Scratch</h3>
<p>Now that we’ve introduced the JAMstack + Serverless architecture and seen why a JAMstack application might need serverless functions, we’ll take a look at the 4 core pieces of infrastructure needed to deploy such an application:</p>
<ol class="indented">
<li><strong>Content Delivery Network</strong></li>
<li><strong>Static Asset Store (Origin)</strong></li>
<li><strong>API Gateway</strong></li>
<li><strong>Serverless Functions</strong></li>
</ol>
<!-- Swiper -->
<div class="swiper-container jam1to4">
<div class="swiper-wrapper">
<div class="swiper-slide">
<figure>
<img src="images/diagrams/Writeup/Carousel/JAMstack + Serverless Infrastructure: CDN 1.png"/>
<figcaption>
<h4>Content Delivery Network</h4>
<p>A content delivery network, or CDN, is a globally distributed network of servers designed to cache web content and serve it to clients with minimal latency. Because of their global scope, client requests can be sent to a CDN server nearest to them, instead of needing to be routed to a central server farther away. This results in much faster response times. In addition, CDNs are highly scalable because increased traffic to an application is automatically spread out to other CDN servers in the proximity of the user.</p>
</figcaption>
</figure>
</div>
<div class="swiper-slide">
<figure>
<img src="images/diagrams/Writeup/Carousel/JAMstack + Serverless Infrastructure: Static Asset Store 2.png"/>
<figcaption>
<h4>Static Asset Store</h4>
<p>The static assets that make up a JAMstack application aren’t actually hosted on CDN servers. Instead, the files need to be stored in a location that acts as a source of truth. This location is known as the “origin”. Files on the origin are retrieved by the CDN and cached before they are served to clients.</p>
</figcaption>
</figure>
</div>
<div class="swiper-slide">
<figure>
<img src="images/diagrams/Writeup/Carousel/JAMstack + Serverless Infrastructure: API Gateway 4.png"/>
<figcaption>
<h4>API Gateway</h4>
<p>Serverless functions aren’t accessible by the client out of the box. In order to allow requests to be sent to serverless functions, an API gateway is needed. To connect a serverless function to the gateway, the route and method that will be used to reach the function must be specified. Then, the function is integrated into the Gateway so that requests sent to the gateway at that route/method combination can be proxied to the function. When a request is received by a function, it gets invoked and the resulting output is returned in a response to the client via the gateway.</p>
</figcaption>
</figure>
</div>
</div>
<div class="swiper-button-next"></div>
<div class="swiper-button-prev"></div>
<div class="swiper-pagination"></div>
</div>
<!-- Initialize Swiper -->
<script>
var swiper = new Swiper(".jam1to4", {
pagination: {
el: ".swiper-pagination",
type: "progressbar",
},
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev",
},
observer: true,
observeParents: true,
});
</script>
<h4>Manually Deploying a JAMstack + Serverless Application</h4>
<p>At a minimum, in order to get a JAMstack application with serverless functions running manually, the 4 pieces of infrastructure discussed above need to be provisioned on a cloud provider. When done using Amazon Web Services through their browser console, more than 50 individual steps are required. Even if the developer knows what to do, this is a tedious and time consuming process.</p>
<video src="images/diagrams/Writeup/Manually_deploying_to_AWS.mov" autoplay style="width: 100%; height: 100%;"type="video/mov" controls loop></video>
<p>There are a number of solutions that streamline this process for developers, avoiding the hassle of provisioning and managing infrastructure so they can instead focus on building the business logic of the application.</p>
</div>
<div id="jamstack-serverless-solution">
<h3>4.2 JAMstack + Serverless Solutions</h3>
<p>These solutions tend to fall into one of two major categories: JAMstack focused or DIY<a href="#reference-9"><sup>9</sup></a>.</p>
<h4>JAMstack Focused Solutions</h4>
<figure>
<img src="images/diagrams/Writeup/Comparison_Netlify_Vercel.png" alt="Diagram comparing netlify and vercel">
</figure>
<p>Netlify and Vercel are two companies we explored that provide a JAMstack focused development experience. They streamline development and take care of the deployment and management of JAMstack applications with serverless functions. With these solutions, a developer writes code and provides some configuration details and they take care of the rest of the work. They also come with many additional useful features like a local development server and continuous deployment via version control tools like Github.</p>
<p>These solutions make creating and deploying JAMstack + serverless applications quick and easy, but they do come with a few tradeoffs:</p>
<ul>
<li>They are not fully open source</li>
<li>Developers do not have direct access to the cloud infrastructure their application runs on, so the ability to customize how applications are deployed and managed is limited.</li>
<li>More stringent limitations are placed on resource use. E.g. Fewer monthly free Lambda invocations and execution time limits on Lambdas.</li>
</ul>
<h4>DIY Solutions</h4>
<figure>
<img src="images/diagrams/Writeup/Comparison_DIY.png" alt="DIY versus JAMStack">
</figure>
<p>DIY solutions generally fall under the heading of Infrastructure as Code, or IAC. IAC tools like Serverless Framework and AWS SAM allow the developer to describe the needed infrastructure in code. Using these tools, developers can create a repeatable, programmatic method of provisioning and deploying JAMstack + Serverless applications. Since you’re creating the infrastructure on your own AWS account, you have access to the underlying infrastructure if you need to customize things later.</p>
<p>The primary downsides of using these DIY solutions are:</p>
<ul>
<li>The steep learning curve</li>
<li>The complexity involved in getting started</li>
</ul>
<h4>Finding a Middle Ground</h4>
<p>After exploring a range of options for creating JAMstack + Serverless applications on both the DIY and JAMstack focused ends of the spectrum, we felt that there was room for a solution that fit somewhere in the middle.</p>
<figure>
<img src="images/diagrams/Writeup/Comparison_JAMstack_DIY.png" alt="">
</figure>
</div>
<div id="introducing-jolt">
<h2>5. Introducing Jolt</h2>
<p>We built Jolt with the goal of providing the ease of use of Netlify or Vercel all on a user’s own infrastructure. Jolt is fully open source and the infrastructure that applications are run on is provisioned on the user’s AWS account to allow for more fine-grained control when it’s needed. We chose AWS as our cloud provider because of its prevalence in the industry and our comfort with the tools and services they provide.</p>
<figure>
<img src="images/diagrams/Writeup/Comparison_All_Jolt.png" alt="Comparing all solutions">
</figure>
</div>
<div id="core-of-jolt">
<h3>5.1 The Core of Jolt</h3>
<p>When we set out to build the core architecture, we decided to start by automating the 50+ steps involved in deploying a JAMstack + serverless application on AWS. Specifically, we wanted to provision: a CDN, a Static Asset Store (Origin), Serverless Functions and an API gateway all on AWS.</p>
<p>We decided to use AWS’ object store, S3, as the origin where static files are stored. Next, we use AWS’ CDN, CloudFront, to retrieve content from S3 and cache it on the global network of CDN servers.</p>
<p>For serverless functions, Jolt uses AWS Lambda. Finally, in order to invoke the Lambdas, an AWS API Gateway instance is created and each Lambda is integrated into the gateway as a separate route.</p>
<figure>
<img src="images/diagrams/Writeup/Jolt_Core.png" alt="Jolt's core diagram">
<figcaption>The core architecture of a Jolt application.</figcaption>
</figure>
</div>
<div id="developing-and-deploying-with-jolt">
<h2>6. Developing and Deploying With Jolt</h2>
<p>With the diagram of the core architecture of a Jolt application in mind, we’ll take a look at the 3 phases involved in deploying an application:</p>
<ol class="indented">
<li>Setup</li>
<li>Building</li>
<li>Deployment</li>
</ol>
<h4>Setup</h4>
<p>In order to provide an easy and intuitive developer experience, Jolt has some guidelines around how developers initialize and structure their applications.</p>
<h4>Initialization</h4>
<figure>
<img src="images/diagrams/Writeup/Gifs/jolt_init.gif" alt="Jolt init command">
</figure>
<p>Before deploying an application, there are a few configuration details Jolt needs. Jolt uses the <strong class="code-snippet">jolt init</strong> command to guide users through a series of prompts that gather this configuration information which is saved to a JSON file for later use. In particular, the information Jolt needs to deploy applications is as follows:</p>
<ol class="indented">
<li><strong>The dependency installation command (ie: npm install):</strong> Ensures that all of the dependencies required by the front-end and Lambdas are installed before deployment begins.</li>
<li><strong>The build command (ie: <em class="code-snippet">npm run build</em>):</strong> Builds the front end codebase into a collection of static assets prior to deployment.</li>
<li><strong>The name of the user’s functions folder:</strong> The location where serverless functions and their environment variables are stored along with any dependencies.</li>
<li><strong>The user’s default AWS region:</strong> Accessed during deployment to specify which region the infrastructure should be provisioned in.</li>
</ol>
<h4>The Functions Folder</h4>
<p>Functions are defined in a separate functions folder located in the root of the application. The functions folder contains a collection of <em class="code-snippet">.js</em> files, each of which represents a Lambda. In addition, a <em class="code-snippet">package.json</em> file is needed in order to include any dependencies required by the functions. Finally, environment variables are defined in a <em class="code-snippet">.env</em> file that lives alongside the functions.</p>
<h4>Creating Functions</h4>
<p> A basic Lambda function looks like this:</p>
<figure>
<img src="images/diagrams/Writeup/sampleFunction.png" alt="A sample Function for jolt">
<figcaption>Each function must conform to the syntax required for all Lambdas, like the example above. (There are some additional parameters that are passed to the function when it is invoked which you can read more about <a href="https://docs.aws.amazon.com/lambda/latest/dg/nodejs-handler.html">here</a>.)</figcaption>
</figure>
<h4>Function Templates</h4>
<p>For users who are unfamiliar with the Lambda syntax, or who want a shortcut for creating a Lambda, entering the command <em class="code-snippet">jolt lambda</em> and the path they want the lambda to have will automatically create a function inside the user’s functions folder.</p>
<figure>
<img src="images/diagrams/Writeup/jolt-functions-demo.gif" alt="jolt Functions Demo">
<figcaption>Creating a function template with <strong class="code-snippet">jolt lambda</strong>.</figcaption>
</figure>
<h4>Building</h4>
<p>Once the application is ready for deployment, the <strong class="code-snippet">jolt deploy</strong> command makes sure that all required dependencies have been installed and then begins the build process using the build command specified by the user during initialization. The specifics of the build process vary depending on the build tool (<strong class="code-snippet">gatsby build</strong>, <strong class="code-snippet">react-scripts build</strong>, etc.) being used, but at a high level the following occurs:</p>
<ol class="indented">
<li>Application code is compiled into a collection of static files</li>
<li>Static files are minified to to reduce file sizes by removing unnecessary white space, truncating variable names, etc. This results in smaller file sizes.</li>
<li>Code is transpiled to use syntax that is supported by older browsers</li>
<li>Wherever possible, code JavaScript, HTML and CSS is bundled into one file to save the client from needing to go through multiple request response cycles for a single page.</li>
</ol>
<p>In addition to the building of front end application code, Jolt also prepares functions for deployment to AWS Lambda. Each function is zipped up along with its dependencies so that the function code and its environment variables can be sent to AWS during the deployment process.</p>
<h4>Deployment</h4>
<p>Jolt deploys a JAMstack + Serverless App with a single command.</p>
<!-- Swiper -->
<div class="swiper-container deploy-jolt">
<div class="swiper-wrapper">
<div class="swiper-slide">
<figure>
<img src="images/diagrams/Writeup/Carousel/Jolt Deploy 0.png"/>
<figcaption><h4>Jolt Deploy</h4>After running <strong class="code-snippet">jolt deploy</strong> from the root of the application, the necessary infrastructure will automatically be provisioned on AWS and the application code along with the serverless functions will be deployed to CloudFront and Lambdas, respectively.</figcaption>
</figure>
</div>
<div class="swiper-slide">
<figure>
<img src="images/diagrams/Writeup/Carousel/Jolt Deploy 1.png"/>
<figcaption>
<h4>Creating a Bucket</h4>
<p>The first step in the deployment process is to create a new bucket on S3. The S3 bucket serves as the origin for content cached on CloudFront.</p>
</figcaption>
</figure>
</div>
<div class="swiper-slide">
<figure>
<img src="images/diagrams/Writeup/Carousel/Jolt Deploy 2.png"/>
<figcaption>
<h4>Creating an API Gateway</h4>
<p>Next, a new API Gateway is created. The gateway is used to proxy client requests to the appropriate Lambda.</p>
</figcaption>
</figure>
</div>
<div class="swiper-slide">
<figure>
<img src="images/diagrams/Writeup/Carousel/Jolt Deploy 3.png"/>
<figcaption>
<h4>Deploying Lambdas</h4>
<p>Since AWS Lambda expects functions to be zipped before they are deployed. each function in the user’s <strong class="code-snippet">functions</strong> folder gets zipped up along with any required dependencies and is sent off to S3 for storage.</p>
<p>For each function, its environment variables (if present) are retrieved from the local environment and a new Lambda is provisioned on AWS from the zipped function code (stored on S3) and the relevant environment variables.</p>
<p>Finally, a new route is created on the API Gateway that matches the path and name of the function within the functions folder and the newly created Lambda is integrated into the Gateway at that route.</p>
</figcaption>
</figure>
</div>
<div class="swiper-slide">
<figure>
<img src="images/diagrams/Writeup/Carousel/Jolt Deploy 4.png"/>
<figcaption>
<h4>Uploading Static Assets</h4>
<p>After creating Lambdas and integrating them into the API Gateway, Jolt deploys the front end of the application. First, the static assets generated during the build process are sent to the S3 bucket.</p>
</figcaption>
</figure>
</div>
<div class="swiper-slide">
<figure>
<img src="images/diagrams/Writeup/Carousel/Jolt Deploy 5.png"/>
<figcaption>
<h4>Configuring CloudFront</h4>
<p>Finally a new distribution is created on CloudFront. To do this, Jolt gives CloudFront the URL of the origin where the built application files are stored on S3. When requests for the application come into CloudFront, the requested content is retrieved from S3 and cached so that subsequent requests can be served without needing to go back to the origin.</p>
<p>Once the CloudFront distribution has been created, CloudFront begins propagating the new distribution to CDN servers all over the globe. This process can take upwards of 10 minutes to finish, but once complete, the new JAMstack + serverless application is live.</p>
</figcaption>
</figure>
</div>
</div>
<div class="swiper-button-next"></div>
<div class="swiper-button-prev"></div>
<div class="swiper-pagination"></div>
</div>
<!-- Initialize Swiper -->
<script>
var swiper = new Swiper(".deploy-jolt", {
pagination: {
el: ".swiper-pagination",
type: "progressbar",
},
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev",
},
observer: true,
observeParents: true,
});
</script>
<p>From the user’s perspective, the 50+ steps involved in manually provisioning and deploying the application are all automated and handled by the <strong class="code-snippet">jolt deploy</strong> command.</p>
</div>
<div id="improving-jolt">
<h2>7. Improving Jolt</h2>
<p>Our initial vision for Jolt was to create a framework that made it easy to deploy JAMstack + serverless applications. With this accomplished, we discovered that there were a number of aspects related to <u>development</u> and <u>management</u> of applications that lacked the ease of use that we wanted to provide with Jolt. So, we decided to improve upon Jolt.</p>
<p>This process proved to have many technical challenges mainly due to two factors: we were <strong>working with cloud infrastructure</strong> and the <strong>JAMstack + serverless architecture was different from a more traditional three-tier architecture</strong>. Below are some of the key features we implemented while improving Jolt:</p>
<ol class="indented">
<li>Relative paths for requests sent from the JAMstack application to serverless functions</li>
<li>Atomic deployment of infrastructure</li>
<li>Easy updates to existing Jolt applications</li>
<li>Rollbacks to revert the application to any previous version</li>