Slide 1

Slide 1 text

2 0 1 8 . 3 . 2 4 M A N A B I YA S e r v e r l e s s f o r F ro n t - e n d S e r v e r- S i d e R e n d e r i n g

Slide 2

Slide 2 text

P ro f i l e • Front-end engineer at PERSOL • GitHub: boiyaa
 Twitter: boiyaaaaaa

Slide 3

Slide 3 text

M o t i v a t i o n I need to consider about measuring SEO. I would like to know easy ways of server-side rendering and hosting that any low-skilled engineers such as me can do.

Slide 4

Slide 4 text

I n f r a s t r u c t u re re q u i re m e n t s f o r S S R In short, wherever Express can be run. I would like to use serverless platform because I do not want to consider about availability.

Slide 5

Slide 5 text

O p t i o n s I t r i e d • AWS stack: Lambda + API Gateway + Cloudfront • Firebase stack: Functions + Hosting

Slide 6

Slide 6 text

I n a d d i t i o n Framework for server-rendered React applications. Server-side rendering React components containing data fetching is bother. This framework makes it easier.

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

P ro c e d u re o f b u i l d i n g i n f r a s t r u c t u re 1. Create a S3 Bucket 2. Create an IAM Role for Lambda 3. Create a Lambda function 4. Create an API as a web site endpoint 5. Add a proxy resource to root resource 6. Add ANY method to the resources 7. Deploy the API 8. Add permission to the Lambda function 9. Create CloudFront Distribution 10. Create a function for Next.js app

Slide 9

Slide 9 text

L a m b d a - E x p re s s i n t e g t a t i o n E x p re s s - N e x t i n t e g t a t i o n

Slide 10

Slide 10 text

P ro c e d u re o f d e p l o y m e n t 1. Build Next.js app 2. Zip the app 3. Upload it to S3 4. Update function code from S3

Slide 11

Slide 11 text

Pros • Flexible CDN cache control. • Flexible access control with AWS WAF. Cons • It takes a few seconds each time cold start due to FaaS • The procedure is complicated. • It takes time to understand configurations. • Should use SAM or Terraform.

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

P ro c e d u re o f b u i l d i n g i n f r a s t r u c t u re 1. Create Firebase configuration file 2. Create a new project 3. Associate the project 4. Create a function for Next.js app

Slide 14

Slide 14 text

F u n c t i o n s - N e x t i n t e g t a t i o n F i re b a s e F u n c t i o n s H T T P t r i g g e r s u p p o r t s E x p re s s a p p

Slide 15

Slide 15 text

P ro c e d u re o f d e p l o y m e n t 1. Build Next.js app 2. Deploy to Firebase

Slide 16

Slide 16 text

Pros • Pretty easy. • Easy GUI and CLI. • Easy CDN cache control and immediate provisioning. • Configuring custom domain is also easy and cert is full-managed. Cons • It takes a few seconds each time cold start due to FaaS • Necessary to visit web console in construction procedure. • No access control system.

Slide 17

Slide 17 text

C o n c l u s i o n s • I love Firebase. • The cases that AWS stack has meaning: • Fetch data from backend built on AWS. • Need to manage with CloudFormation or Terraform. • Need to have ACL on platform side. • Google App Engine Node.js standard environment is in Early Access Program. This might resolve cold start problem.

Slide 18

Slide 18 text

E x a m p l e s h t t p s : / / g i t h u b . c o m / b o i y a a / f ro n t e n d - s e r v e r l e s s - p a t t e r n s

Slide 19

Slide 19 text

T h a n k y o u