apidays australia - openresty for scale

65
@developersteve #APIDaysAU OpenResty Building APIs for scale with

Upload: steven-cooper

Post on 12-Apr-2017

96 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

OpenRestyBuilding APIs for scale with

Page 2: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Page 3: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Steven CooperSniip CTODevelopersteve.com

As Chief Technology Officer for Sniip Steven is working closely to help scale the platform and creating new innovative ways for consumers to pay. With Sniip’s frictionless and easy to use application he is working with government agencies, councils and utility companies to implement the technology.

Page 4: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

About USSniip is a disruptive force in the payment space

It is the first of its kind in Australia as it is a mobile payment application built not around a bank or payment brand, but rather, around the consumer.

About SniipWhere it started

Page 5: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

SCAN CHECKOUT

How it WorksThe easy way to pay

PIN

Page 6: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Other “solutions”Such advanced technology

Page 7: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Page 8: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Our Legacy StackIt has to start somewhere

Page 9: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Page 10: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

<3 AWS

Page 11: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Laravel API’sPhp framework

Page 12: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

PHP is a frameworkhttp://phpthewrongway.com

Page 13: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Mysql SchemaMysql architecture

Page 14: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Our StrategyRebuilding for scale, elasticity and futureproofing

UX/UICreate a user

experience that futureproofs the UX

FunctionalityBuilding relevant functionality that allows for scale

Developer Portal

API’s and Documentation built

for internal and external

User EngagementEnsuring we build how users want to use our platform

Page 15: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Page 16: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

The StackOpenresty

Page 17: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

OpenRestyA fusion between Nginx and Lua

Page 18: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

OpenResty Market ShareUsed by nearly half a million websites

https://wappalyzer.com/categories/web-servers

Page 19: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Powering TumblrUsed by high traffic sites

https://news.netcraft.com/archives/2016/09/19/september-2016-web-server-survey.html

Page 20: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

OpenResty Libshttps://devstev.es/orlibs

Page 21: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

OpenResty Machine Learninghttp://torch.ch/

Page 22: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

<3 NginxNginx is awesome

Page 23: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Lua is back … againCant beat a classic

Page 24: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Corona SDKCross platform mobile

Page 25: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Let’s EncryptAutomatically renewable SSL

Page 26: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Auto renew SSLhttps://devstev.es/autossl

Page 27: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Auto renew SSLhttps://devstev.es/autossl2

Page 28: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

PCI DSS 3.2Payment Card Industry Data Security Standard

Page 29: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Implement TLSA more secure connection

TLS 1.0

TLS 1.1

TLS 1.2

Page 30: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Page 31: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

ConfigurationSetting up the

Page 32: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Installing OpenRestyopenresty.org

Page 33: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Openresty NginxConfig nginx.conf

./configure --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid

Page 34: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Openresty Libraries https://devstev.es/orlibs

--with-luajit --with-pcre-jit --with-debug --with-http_auth_request_module --with-http_geoip_module --with-http_gzip_static_module --with-http_ssl_module --with-ipv6 --with-http_v2_module --with-http_postgres_module

Page 35: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Make… Install…

Page 36: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Page 37: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Nginx.conf LoadbalanceNginx as per normal

Page 38: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Nginx.conf BasicNginx as per normal

worker_processes auto;

error_log logs/error.log;

events { worker_connections 1024;}

http { server {

}}

Page 39: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Nginx.conf SSL/TLSNginx as per normal

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;ssl_prefer_server_ciphers on; ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";ssl_ecdh_curve secp384r1; ssl_session_timeout 1d;ssl_session_cache shared:SSL:10m;ssl_session_tickets off;ssl_stapling on;ssl_stapling_verify on;listen 443 ssl http2;listen [::]:443 ssl http2;ssl_certificate /etc/letsencrypt/live/website.com/fullchain.pem;ssl_certificate_key /etc/letsencrypt/live/website.com/privkey.pem;add_header X-Frame-Options DENY;add_header X-Content-Type-Options nosniff;add_header X-XSS-Protection "1; mode=block";

Page 40: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Page 41: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Nginx.conf additionalsNginx setup

http {init_by_lua ’ json = require "cjson";';

}

Page 42: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Nginx.conf RoutesRouting like a boss

location / { content_by_lua_file ”./hello.lua";

}

Page 43: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Calling in Lua helloworl.lua

local cjson = require("cjson")

ngx.status = ngx.HTTP_OKngx.header.content_type = "application/json; charset=utf-8”ngx.say(cjson.encode({ hello = "world" }))return ngx.exit(ngx.HTTP_OK)

Page 44: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Run OpenResty Run Fingers crossed

nginx -p `pwd`/ -c nginx.conf

Page 45: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Nginx.conf RoutesRouting like a boss

location / { content_by_lua_file ”./hello.lua";

}

location ~/status { content_by_lua_file ”./status.lua";

}

Page 46: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Calling in Lua Return a status

local cjson = require("cjson")

ngx.status = ngx.HTTP_OKngx.header.content_type = "application/json; charset=utf-8”ngx.say(cjson.encode({ status = true }))return ngx.exit(ngx.HTTP_OK)

Page 47: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Page 48: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Template Engine Lua https://devstev.es/luatemp

Page 49: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

OpenResty Snippets https://devstev.es/luasnip

Page 50: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Load TestingI feel the need for speed

Page 51: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Page 52: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Page 53: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

BlitzIOhttps://blitz.io

Page 54: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Legacy

Page 55: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

OpenResty

Page 56: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Response TimesLeft is legacy – Right is new

OpenRestyLegacy

Page 57: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Hit RateLeft is legacy – Right is new

OpenRestyLegacy

Page 58: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Page 59: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

ReadingRecommended

Page 60: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Designing robust API’shttps://devstev.es/api1

Page 61: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

What is OpenRestyhttps://devstev.es/api2

Page 62: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Moltin OpenRestyhttps://devstev.es/api3

Page 63: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Thanks

Questions? Comments?

Page 64: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

8-Bit Open Source

Page 65: APIDays Australia - Openresty for scale

@developersteve #APIDaysAU

Drop Microphone

Walk off stage