Slide 1

Slide 1 text

WAMP as a platform for composite SOA applications and its implementation on Lua Konstantin Burkalev @KSDaemon

Slide 2

Slide 2 text

Few words about me… 2 • Software architect • 15+ years in IT • Author and host of podcasts: SDCast & RadioJS • Active member of WAMP protocol development group • Author and maintainer of a few WAMP implementations, some of them are written in Lua

Slide 3

Slide 3 text

Talk plan Example of system using WAMP What is WAMP and how it works WAMP as basis for SOA applications Application fields WAMP client in Lua WAMP router in Nginx/Lua 3

Slide 4

Slide 4 text

Task: Smart Home System 4

Slide 5

Slide 5 text

Living room Task: Smart Home System 4

Slide 6

Slide 6 text

Living room Task: Smart Home System 4

Slide 7

Slide 7 text

Living room Task: Smart Home System 4

Slide 8

Slide 8 text

Bath room Living room Task: Smart Home System 4

Slide 9

Slide 9 text

Bath room Living room Task: Smart Home System 4

Slide 10

Slide 10 text

Bath room Living room Task: Smart Home System 4

Slide 11

Slide 11 text

Bath room Living room Task: Smart Home System 4 User

Slide 12

Slide 12 text

Bath room Living room Task: Smart Home System 4 User

Slide 13

Slide 13 text

The temperature sensor detects the temperature raise Bath room Living room Task: Smart Home System 4 User

Slide 14

Slide 14 text

The client is notified Logged in database Bath room Living room Task: Smart Home System 4 User

Slide 15

Slide 15 text

The client is notified Logged in database Bath room Living room Task: Smart Home System 4 User

Slide 16

Slide 16 text

The system turns on air conditioning Bath room Living room Task: Smart Home System 4 User

Slide 17

Slide 17 text

The temperature in the room decreases Bath room Living room Task: Smart Home System 4 User

Slide 18

Slide 18 text

Bath room Living room Task: Smart Home System 4 User

Slide 19

Slide 19 text

Bath room Living room Task: Smart Home System 4 User

Slide 20

Slide 20 text

The system turns off the air conditioning Bath room Living room Task: Smart Home System 4 User

Slide 21

Slide 21 text

The system turns off the air conditioning Bath room Living room Task: Smart Home System 4 User

Slide 22

Slide 22 text

The humidity in the bathroom rises Bath room Living room Task: Smart Home System 4 User

Slide 23

Slide 23 text

The client is notified Logged in database Bath room Living room Task: Smart Home System 4 User

Slide 24

Slide 24 text

The client is notified Logged in database Bath room Living room Task: Smart Home System 4 User

Slide 25

Slide 25 text

The system turns on a fan Bath room Living room Task: Smart Home System 4 User

Slide 26

Slide 26 text

The system turns on a fan Bath room Living room Task: Smart Home System 4 User

Slide 27

Slide 27 text

The humidity in the bathroom drops Bath room Living room Task: Smart Home System 4 User

Slide 28

Slide 28 text

Bath room Living room Task: Smart Home System 4 User

Slide 29

Slide 29 text

Bath room Living room Task: Smart Home System 4 User

Slide 30

Slide 30 text

The system turns off the fan Bath room Living room Task: Smart Home System 4 User

Slide 31

Slide 31 text

The system turns off the fan Bath room Living room Task: Smart Home System 4 User

Slide 32

Slide 32 text

Bath room Living room Task: Smart Home System 4 User Admin

Slide 33

Slide 33 text

Admin configures threshold values Bath room Living room Task: Smart Home System 4 User Admin

Slide 34

Slide 34 text

Admin searches new devices Bath room Living room Task: Smart Home System 4 User Admin

Slide 35

Slide 35 text

The system informs about found devices Bath room Living room Task: Smart Home System 4 User Admin

Slide 36

Slide 36 text

The system informs about found devices Bath room Living room Task: Smart Home System 4 User Admin

Slide 37

Slide 37 text

Bath room Living room Task: Smart Home System 4 User Admin

Slide 38

Slide 38 text

What is WAMP 5

Slide 39

Slide 39 text

What is WAMP • It stands for "Web Application Messaging Protocol" 5

Slide 40

Slide 40 text

What is WAMP • It stands for "Web Application Messaging Protocol" • Is intended for communication between software components in near real-time 5

Slide 41

Slide 41 text

What is WAMP • It stands for "Web Application Messaging Protocol" • Is intended for communication between software components in near real-time • Provides two mechanisms: • Publish/Subscribe (PubSub) • Remote Procedure Calls (RPC) 5

Slide 42

Slide 42 text

What is WAMP • It stands for "Web Application Messaging Protocol" • Is intended for communication between software components in near real-time • Provides two mechanisms: • Publish/Subscribe (PubSub) • Remote Procedure Calls (RPC) • Bi-directional, ordered 5

Slide 43

Slide 43 text

What is WAMP • It stands for "Web Application Messaging Protocol" • Is intended for communication between software components in near real-time • Provides two mechanisms: • Publish/Subscribe (PubSub) • Remote Procedure Calls (RPC) • Bi-directional, ordered • For communication between clients is required WAMP-router 5

Slide 44

Slide 44 text

Why WAMP? 6

Slide 45

Slide 45 text

Why WAMP? • Open specification 6

Slide 46

Slide 46 text

Why WAMP? • Open specification • Thoughtful Publish / Subscribe 6

Slide 47

Slide 47 text

Why WAMP? • Open specification • Thoughtful Publish / Subscribe • Thoughtful Remote Procedure Calls 6

Slide 48

Slide 48 text

Why WAMP? • Open specification • Thoughtful Publish / Subscribe • Thoughtful Remote Procedure Calls • Message routing 6

Slide 49

Slide 49 text

Why WAMP? • Open specification • Thoughtful Publish / Subscribe • Thoughtful Remote Procedure Calls • Message routing • Cross-platform 6

Slide 50

Slide 50 text

Why WAMP? • Open specification • Thoughtful Publish / Subscribe • Thoughtful Remote Procedure Calls • Message routing • Cross-platform • There are implementations in more than 15 languages 6

Slide 51

Slide 51 text

WAMP alternatives 7 Technology PubSub RPC Routed RPC Web native Cross Language Open Standard WAMP ✔ ✔ ✔ ✔ ✔ ✔ AJAX - ✔ - ✔ ✔ - AMQP ✔ (✔) - - ✔ ✔ Java JMS ✔ - - - - ✔ JSON-RPC - ✔ - ✔ ✔ ✔ MQTT ✔ - - - ✔ ✔ REST - ✔ - ✔ ✔ - SOAP - ✔ - ✔ ✔ ✔ socket.io ✔ - - ✔ - - XMPP ✔ - - ✔ ✔ ✔ ZMQ ✔ - - - ✔ -

Slide 52

Slide 52 text

WAMP: message examples 8

Slide 53

Slide 53 text

WAMP architecture 9

Slide 54

Slide 54 text

WAMP architecture 10 Client. Can provide or consume resources such as subscriptions and RPC.

Slide 55

Slide 55 text

WAMP architecture 11 Router. Deals with authorization and routing messages between clients.

Slide 56

Slide 56 text

WAMP architecture 12 Peer. Can be a client or a router, must have at least one role.

Slide 57

Slide 57 text

WAMP architecture 13 Role. Defines features of the node. There are 4 client roles and 2 roles of the router.

Slide 58

Slide 58 text

WAMP architecture 14 Session. It is necessary for identification and authorization of clients, announce the roles of nodes.

Slide 59

Slide 59 text

WAMP architecture 15 Realm. domain, namespace, single space within which resources and message routing takes place.

Slide 60

Slide 60 text

WAMP architecture 16 Transport. You can use: Websocket, Raw TCP, Unix sockets and even HTTP Long poll.

Slide 61

Slide 61 text

WAMP architecture 17 Serializer. All messages are serialized using JSON/MessagePack/ CBOR. message

Slide 62

Slide 62 text

WAMP architecture 18 Resource identifiers, URI. Required for topics, procedures and errors. For example: Topic: «sensor.events» RPC: «discover.devices» message

Slide 63

Slide 63 text

Basic WAMP concepts 19

Slide 64

Slide 64 text

Basic WAMP concepts • Client. Can provide or consume resources, such as subscriptions and RPC. • Router. Deals with authorization and message routing between clients. • Peer. Can be a client or a router, must have at least one role. • Role. Determines the capabilities of the node. There are 4 client roles and 2 router roles. • Session. It is necessary to identify and authorize clients, announce the role of nodes. • Realm. Domain, namespace, within which messages are routed. • Transport. You can use: WebSockets, Raw TCP, Unix sockets and even HTTP Long poll. • Serializer. Messages are serialized using JSON / MessagePack / CBOR / etc. • Resource identifiers, URIs. Required for topics, procedures and errors. 19

Slide 65

Slide 65 text

WAMP: Features 20

Slide 66

Slide 66 text

WAMP: Features • Basic profile: basic features of RPC and PubSub 20

Slide 67

Slide 67 text

WAMP: Features • Basic profile: basic features of RPC and PubSub • Advanced profile: 20

Slide 68

Slide 68 text

WAMP: Features • Basic profile: basic features of RPC and PubSub • Advanced profile: • Challenge-Response Authentication • Progressive call results, call timeout, call canceling • Publication / call trust levels • Caller / publisher identification • Pattern based registration / subscription • Shared registration, sharded registration / subscription • Event history • Meta API & Procedure / topic reflection 20

Slide 69

Slide 69 text

WAMP: session establishment 21 Client Router Realm

Slide 70

Slide 70 text

WAMP: session establishment 21 HELLO Client Router Realm [1, "homeapp", { "roles": { "publisher": {}, "subscriber": {} } }]

Slide 71

Slide 71 text

WAMP: session establishment 21 HELLO WELCOME Client Router Realm [2, 9129137332, { "roles": { "broker": {} } }]

Slide 72

Slide 72 text

WAMP: session establishment 21 HELLO WELCOME ABORT Client Router Realm [3, {"message": "The realm does not exist."}, "wamp.error.no_such_realm"]

Slide 73

Slide 73 text

WAMP: session establishment 21 HELLO WELCOME GOODBYE (init by client) ABORT Client Router Realm [6, {"message": "The host is shutting down now."}, "wamp.error.system_shutdown"]

Slide 74

Slide 74 text

WAMP: session establishment 21 HELLO WELCOME GOODBYE (init by client) ABORT GOODBYE Client Router Realm [6, {}, "wamp.error.goodbye_and_out"]

Slide 75

Slide 75 text

WAMP: session establishment 21 HELLO WELCOME GOODBYE (init by client) ABORT GOODBYE GOODBYE (init by router) Client Router Realm [6, {}, "wamp.error.close_realm"]

Slide 76

Slide 76 text

WAMP: session establishment 21 HELLO WELCOME GOODBYE (init by client) ABORT GOODBYE GOODBYE GOODBYE (init by router) Client Router Realm [6, {}, "wamp.error.goodbye_and_out"]

Slide 77

Slide 77 text

WAMP: session establishment 21 HELLO WELCOME GOODBYE (init by client) ABORT GOODBYE GOODBYE GOODBYE (init by router) Client Router Realm

Slide 78

Slide 78 text

WAMP: Publish / Subscribe 22 Publisher Broker Subscriber Realm

Slide 79

Slide 79 text

WAMP: Publish / Subscribe 22 SUBSCRIBE Publisher Broker Subscriber Realm [32, 713845233, {}, "sensor.events"]

Slide 80

Slide 80 text

WAMP: Publish / Subscribe 22 SUBSCRIBE SUBSCRIBED Publisher Broker Subscriber Realm [33, 713845233, 5512315355]

Slide 81

Slide 81 text

WAMP: Publish / Subscribe 22 SUBSCRIBE SUBSCRIBED ERROR Publisher Broker Subscriber Realm [8, 32, 713845233, {}, "wamp.error.not_authorized"]

Slide 82

Slide 82 text

WAMP: Publish / Subscribe 22 SUBSCRIBE SUBSCRIBED ERROR PUBLISH Publisher Broker Subscriber Realm [16, 239714735, {}, "sensor.events", [], {"sensorId ": 25, "temp": 27}]

Slide 83

Slide 83 text

WAMP: Publish / Subscribe 22 SUBSCRIBE SUBSCRIBED ERROR PUBLISH PUBLISHED Publisher Broker Subscriber Realm [17, 239714735, 4429313566]

Slide 84

Slide 84 text

WAMP: Publish / Subscribe 22 SUBSCRIBE SUBSCRIBED ERROR PUBLISH PUBLISHED ERROR Publisher Broker Subscriber Realm [8, 16, 239714735, {}, "wamp.error.not_authorized"]

Slide 85

Slide 85 text

WAMP: Publish / Subscribe 22 SUBSCRIBE SUBSCRIBED ERROR PUBLISH PUBLISHED ERROR EVENT Publisher Broker Subscriber Realm [36, 5512315355, 4429313566, {}, [], {"sensorId ": 25, "temp": 27}]

Slide 86

Slide 86 text

WAMP: Publish / Subscribe 22 SUBSCRIBE SUBSCRIBED UNSUBSCRIBE ERROR PUBLISH PUBLISHED ERROR EVENT Publisher Broker Subscriber Realm [34, 85346237, 5512315355]

Slide 87

Slide 87 text

WAMP: Publish / Subscribe 22 SUBSCRIBE SUBSCRIBED UNSUBSCRIBE UNSUBSCRIBED ERROR PUBLISH PUBLISHED ERROR EVENT Publisher Broker Subscriber Realm [35, 85346237]

Slide 88

Slide 88 text

WAMP: Publish / Subscribe 22 SUBSCRIBE SUBSCRIBED UNSUBSCRIBE UNSUBSCRIBED ERROR ERROR PUBLISH PUBLISHED ERROR EVENT Publisher Broker Subscriber Realm [8, 34, 85346237, {}, "wamp.error.no_such_subscription"]

Slide 89

Slide 89 text

WAMP: Publish / Subscribe 22 SUBSCRIBE SUBSCRIBED UNSUBSCRIBE UNSUBSCRIBED ERROR ERROR PUBLISH PUBLISHED ERROR EVENT Publisher Broker Subscriber Realm

Slide 90

Slide 90 text

WAMP: Remote Procedure Calls 23 Caller Dealer Callee Realm

Slide 91

Slide 91 text

WAMP: Remote Procedure Calls 23 Caller Dealer Callee REGISTER Realm [64, 25349185, {}, "dcs.fan.control"]

Slide 92

Slide 92 text

WAMP: Remote Procedure Calls 23 Caller Dealer Callee REGISTER REGISTERED Realm [65, 25349185, 2103333224]

Slide 93

Slide 93 text

WAMP: Remote Procedure Calls 23 Caller Dealer Callee REGISTER REGISTERED ERROR Realm [8, 64, 25349185, {}, "wamp.error.procedure_already_exists"]

Slide 94

Slide 94 text

WAMP: Remote Procedure Calls 23 Caller Dealer Callee REGISTER REGISTERED ERROR CALL Realm [48, 7814135, {}, "dcs.fan.control", [true]]

Slide 95

Slide 95 text

WAMP: Remote Procedure Calls 23 Caller Dealer Callee REGISTER REGISTERED ERROR CALL INVOCATION Realm [68, 6131533, 9823528, {}, [true]]

Slide 96

Slide 96 text

WAMP: Remote Procedure Calls 23 Caller Dealer Callee REGISTER REGISTERED ERROR CALL INVOCATION YIELD Realm [70, 6131533, {}]

Slide 97

Slide 97 text

WAMP: Remote Procedure Calls 23 Caller Dealer Callee REGISTER REGISTERED ERROR CALL RESULT INVOCATION YIELD Realm [50, 7814135, {}]

Slide 98

Slide 98 text

WAMP: Remote Procedure Calls 23 Caller Dealer Callee REGISTER REGISTERED ERROR CALL RESULT INVOCATION YIELD ERROR Realm [8, 68, 6131533, {}, "homeapp.error.hardware_not_found"]

Slide 99

Slide 99 text

WAMP: Remote Procedure Calls 23 Caller Dealer Callee REGISTER REGISTERED ERROR CALL RESULT INVOCATION YIELD ERROR ERROR Realm [8, 48, 7814135, {}, "homeapp.error.hardware_not_found"]

Slide 100

Slide 100 text

WAMP: Remote Procedure Calls 23 Caller Dealer Callee REGISTER REGISTERED UNREGISTER ERROR CALL RESULT INVOCATION YIELD ERROR ERROR Realm [66, 788923562, 2103333224]

Slide 101

Slide 101 text

WAMP: Remote Procedure Calls 23 Caller Dealer Callee REGISTER REGISTERED UNREGISTER UNREGISTERED ERROR CALL RESULT INVOCATION YIELD ERROR ERROR Realm [67, 788923562]

Slide 102

Slide 102 text

WAMP: Remote Procedure Calls 23 Caller Dealer Callee REGISTER REGISTERED UNREGISTER UNREGISTERED ERROR ERROR CALL RESULT INVOCATION YIELD ERROR ERROR Realm [8, 66, 788923562, {}, "wamp.error.no_such_registration"]

Slide 103

Slide 103 text

WAMP: Remote Procedure Calls 23 Caller Dealer Callee REGISTER REGISTERED UNREGISTER UNREGISTERED ERROR ERROR CALL RESULT INVOCATION YIELD ERROR ERROR Realm

Slide 104

Slide 104 text

WAMP as a basis for SOA applications 24

Slide 105

Slide 105 text

WAMP as a basis for SOA applications Distributed architecture 24

Slide 106

Slide 106 text

WAMP as a basis for SOA applications Distributed architecture Loose coupling of components 24

Slide 107

Slide 107 text

WAMP as a basis for SOA applications Distributed architecture Loose coupling of components A simple and intuitive interface for interaction 24

Slide 108

Slide 108 text

WAMP as a basis for SOA applications Distributed architecture Loose coupling of components A simple and intuitive interface for interaction Unified Routing 24

Slide 109

Slide 109 text

WAMP as a basis for SOA applications Distributed architecture Loose coupling of components A simple and intuitive interface for interaction Unified Routing Independence from programming language 24

Slide 110

Slide 110 text

WAMP as a basis for SOA applications Distributed architecture Loose coupling of components A simple and intuitive interface for interaction Unified Routing Independence from programming language Re-usability of components 24

Slide 111

Slide 111 text

WAMP as a basis for SOA applications Distributed architecture Loose coupling of components A simple and intuitive interface for interaction Unified Routing Independence from programming language Re-usability of components WAMP satisfies the requirements of SOA 24

Slide 112

Slide 112 text

WAMP as ESB 25 WAMP Router Service Providers Service Providers Service Providers Service Providers Service Providers Consumers Consumers Consumers Consumers Consumers call RPC Subscribe to topics Register RPC Publish events Subscribe to topics Publish events Сервер Сервер Server

Slide 113

Slide 113 text

WAMP in heterogeneous systems 26 WAMP Router File uploader (python) Web Client (js) Backoffice Client (c#) Video processing (c++) Image processing (go) Logger (ruby) External API Gateway Client REST API (nodejs) Mobile Client (swift) Backoffice REST API (Java) DB Mobile Client (java) Realm Realm Realm Сервер Сервер Server

Slide 114

Slide 114 text

WAMP Application fields 27

Slide 115

Slide 115 text

WAMP Application fields 27 Distributed applications with a large number of services

Slide 116

Slide 116 text

WAMP Application fields 27 Distributed applications with a large number of services Smart homes, Smart cities, Internet of things in General

Slide 117

Slide 117 text

WAMP Application fields 27 Distributed applications with a large number of services Smart homes, Smart cities, Internet of things in General Systems with long-running processes

Slide 118

Slide 118 text

WAMP Application fields 27 Distributed applications with a large number of services Smart homes, Smart cities, Internet of things in General Systems with long-running processes Easy modern alternative to XMPP, XMLRPC

Slide 119

Slide 119 text

WAMP Application fields 27 Distributed applications with a large number of services Smart homes, Smart cities, Internet of things in General Systems with long-running processes Easy modern alternative to XMPP, XMLRPC Network multiplayer games

Slide 120

Slide 120 text

WAMP: real projects 28

Slide 121

Slide 121 text

WAMP: real projects • Kadecot API Server. Sony Computer Science Laboratories 28

Slide 122

Slide 122 text

WAMP: real projects • Kadecot API Server. Sony Computer Science Laboratories • ParaView. Parallel Data Analysis and Visualization Application, Kitware 28

Slide 123

Slide 123 text

WAMP: real projects • Kadecot API Server. Sony Computer Science Laboratories • ParaView. Parallel Data Analysis and Visualization Application, Kitware • Record.Evolution. Data-warehouse and Business Intelligence 28

Slide 124

Slide 124 text

WAMP: real projects • Kadecot API Server. Sony Computer Science Laboratories • ParaView. Parallel Data Analysis and Visualization Application, Kitware • Record.Evolution. Data-warehouse and Business Intelligence • SmartME smart city project. MDS Lab at the University of Messina 28

Slide 125

Slide 125 text

WAMP: real projects • Kadecot API Server. Sony Computer Science Laboratories • ParaView. Parallel Data Analysis and Visualization Application, Kitware • Record.Evolution. Data-warehouse and Business Intelligence • SmartME smart city project. MDS Lab at the University of Messina • ButterflyDNS. Web UI frontend for BIND DLZ • Gollard VISION Server Management Subsystem 28

Slide 126

Slide 126 text

Health monitor Nginx Server Management Subsystem 29 WAMP Router Admin App (c#) Shaman RPC: set.network RPC: get.network Publish: status.change RPC: get.status RPC: get.time RPC: set.time

Slide 127

Slide 127 text

Loowy: WAMP client in Lua 30

Slide 128

Slide 128 text

Loowy: WAMP client in Lua 30 • Works in Lua/Luajit environment on top of lua-ev

Slide 129

Slide 129 text

Loowy: WAMP client in Lua 30 • Works in Lua/Luajit environment on top of lua-ev • Supports JSON and Msgpack serializers

Slide 130

Slide 130 text

Loowy: WAMP client in Lua 30 • Works in Lua/Luajit environment on top of lua-ev • Supports JSON and Msgpack serializers • Supports a number of features from Advanced Profile

Slide 131

Slide 131 text

Loowy: WAMP client in Lua 30 • Works in Lua/Luajit environment on top of lua-ev • Supports JSON and Msgpack serializers • Supports a number of features from Advanced Profile • Automatic reconnection and re-subscription

Slide 132

Slide 132 text

Loowy: WAMP client in Lua 30 • Works in Lua/Luajit environment on top of lua-ev • Supports JSON and Msgpack serializers • Supports a number of features from Advanced Profile • Automatic reconnection and re-subscription • TODO: Raw socket transport • TODO: Meta API • TODO: Challenge-Response Authorization (WAMP-CRA) • TODO: work on the basis of coroutines

Slide 133

Slide 133 text

Loowy: api calls examples 31 client = loowy.new("ws://localhost/ws/", { realm = "gv" }) client:publish('sensor.events', { sensorId = 12, temperature = 27}) client:subscribe('sensor.events', function(event) -- process received event end) client:call('dcs.fan.control', true, { onSuccess = function() -- fan turned on successfully end, onError = function(err) -- error occurred end })

Slide 134

Slide 134 text

Loowy: Technology stack 32

Slide 135

Slide 135 text

Loowy: Technology stack 32 • Lua 5.1+, Luajit 2.0 • lua-websockets (which uses luasocket under the hood) • lua-ev • lua-rapidjson • lua-MessagePack (optional)

Slide 136

Slide 136 text

Wiola: WAMP router in Lua 33

Slide 137

Slide 137 text

Wiola: WAMP router in Lua • Works on top of Nginx/Lua module 33

Slide 138

Slide 138 text

Wiola: WAMP router in Lua • Works on top of Nginx/Lua module • Uses Redis for runtime storage 33

Slide 139

Slide 139 text

Wiola: WAMP router in Lua • Works on top of Nginx/Lua module • Uses Redis for runtime storage • Supports JSON and Msgpack serializers 33

Slide 140

Slide 140 text

Wiola: WAMP router in Lua • Works on top of Nginx/Lua module • Uses Redis for runtime storage • Supports JSON and Msgpack serializers • Supports a number of features from Advanced Profile 33

Slide 141

Slide 141 text

Wiola: WAMP router in Lua • Works on top of Nginx/Lua module • Uses Redis for runtime storage • Supports JSON and Msgpack serializers • Supports a number of features from Advanced Profile • TODO: Raw socket transport • TODO: Meta API • TODO: lua-resty-postgres 33

Slide 142

Slide 142 text

Wiola: Technology stack 34

Slide 143

Slide 143 text

Wiola: Technology stack 34 • Nginx or OpenResty, simply put lua-nginx-module • lua-resty-websocket • lua-resty-redis • Redis Server • lua-rapidjson • lua-resty-hmac (optional, is required for WAMP-CRA) • lua-MessagePack (optional)

Slide 144

Slide 144 text

Wiola: Nginx config 35 location /ws/ { set $wiola_socket_timeout 10; set $wiola_max_payload_len 65535; lua_check_client_abort on; header_filter_by_lua_file /lib/wiola/headers.lua; content_by_lua_file /lib/wiola/handler.lua; }

Slide 145

Slide 145 text

Nginx Wiola: Common scheme 36 Web Client init_by_lua headers_filter_by_lua content_by_lua Redis Server

Slide 146

Slide 146 text

Wiola: JSON caveats and limitations 37

Slide 147

Slide 147 text

Wiola: JSON caveats and limitations • cJSON 37

Slide 148

Slide 148 text

Wiola: JSON caveats and limitations • cJSON • you cannot specify how to serialize empty tables 37

Slide 149

Slide 149 text

Wiola: JSON caveats and limitations • cJSON • you cannot specify how to serialize empty tables • lua-resty-libcjson 37

Slide 150

Slide 150 text

Wiola: JSON caveats and limitations • cJSON • you cannot specify how to serialize empty tables • lua-resty-libcjson • not able to work with large numbers (int > 32bit) 37

Slide 151

Slide 151 text

Wiola: JSON caveats and limitations • cJSON • you cannot specify how to serialize empty tables • lua-resty-libcjson • not able to work with large numbers (int > 32bit) lua-rapidjson 37

Slide 152

Slide 152 text

Wiola: JSON caveats and limitations • cJSON • you cannot specify how to serialize empty tables • lua-resty-libcjson • not able to work with large numbers (int > 32bit) lua-rapidjson • So far, no new problems have been found :) 37

Slide 153

Slide 153 text

Wiola: Runtime storage options 38

Slide 154

Slide 154 text

Wiola: Runtime storage options 38 • Global variables in memory

Slide 155

Slide 155 text

Wiola: Runtime storage options 38 • Global variables in memory • are created every time on request handler

Slide 156

Slide 156 text

Wiola: Runtime storage options 38 • Global variables in memory • are created every time on request handler • problems with concurrent requests

Slide 157

Slide 157 text

Wiola: Runtime storage options 38 • Global variables in memory • are created every time on request handler • problems with concurrent requests • Module variables loaded in init_by_lua

Slide 158

Slide 158 text

Wiola: Runtime storage options 38 • Global variables in memory • are created every time on request handler • problems with concurrent requests • Module variables loaded in init_by_lua • You can read in all workers

Slide 159

Slide 159 text

Wiola: Runtime storage options 38 • Global variables in memory • are created every time on request handler • problems with concurrent requests • Module variables loaded in init_by_lua • You can read in all workers • But the write, thanks to CoW, will create a copy of the module for the VM

Slide 160

Slide 160 text

Wiola: Runtime storage options 38 • Global variables in memory • are created every time on request handler • problems with concurrent requests • Module variables loaded in init_by_lua • You can read in all workers • But the write, thanks to CoW, will create a copy of the module for the VM • ngx.shared.DICT

Slide 161

Slide 161 text

Wiola: Runtime storage options 38 • Global variables in memory • are created every time on request handler • problems with concurrent requests • Module variables loaded in init_by_lua • You can read in all workers • But the write, thanks to CoW, will create a copy of the module for the VM • ngx.shared.DICT • The size of each dictionary is specified in the config file and can not be changed

Slide 162

Slide 162 text

Wiola: Runtime storage options 38 • Global variables in memory • are created every time on request handler • problems with concurrent requests • Module variables loaded in init_by_lua • You can read in all workers • But the write, thanks to CoW, will create a copy of the module for the VM • ngx.shared.DICT • The size of each dictionary is specified in the config file and can not be changed External storage: Redis, Memcache, PostgreSQL, MySQL and others

Slide 163

Slide 163 text

Wiola: Особенности. lua_code_cache 39

Slide 164

Slide 164 text

Wiola: Особенности. lua_code_cache 39 • lua_code_cache off;

Slide 165

Slide 165 text

Wiola: Особенности. lua_code_cache 39 • lua_code_cache off; • it is convenient to debug the code

Slide 166

Slide 166 text

Wiola: Особенности. lua_code_cache 39 • lua_code_cache off; • it is convenient to debug the code • every require() is executed again in each request

Slide 167

Slide 167 text

Wiola: Особенности. lua_code_cache 39 • lua_code_cache off; • it is convenient to debug the code • every require() is executed again in each request • Even the modules loaded into init_by_lua are re-executed

Slide 168

Slide 168 text

Wiola: Особенности. lua_code_cache 39 • lua_code_cache off; • it is convenient to debug the code • every require() is executed again in each request • Even the modules loaded into init_by_lua are re-executed • lua_code_cache on;

Slide 169

Slide 169 text

Wiola: Особенности. lua_code_cache 39 • lua_code_cache off; • it is convenient to debug the code • every require() is executed again in each request • Even the modules loaded into init_by_lua are re-executed • lua_code_cache on; • for production environment

Slide 170

Slide 170 text

Wiola: Особенности. lua_code_cache 39 • lua_code_cache off; • it is convenient to debug the code • every require() is executed again in each request • Even the modules loaded into init_by_lua are re-executed • lua_code_cache on; • for production environment • each require() is executed once and is cached

Slide 171

Slide 171 text

Wiola: Особенности. lua_code_cache 39 • lua_code_cache off; • it is convenient to debug the code • every require() is executed again in each request • Even the modules loaded into init_by_lua are re-executed • lua_code_cache on; • for production environment • each require() is executed once and is cached • whenever you change the code, you need to reload nginx

Slide 172

Slide 172 text

Wiola: Publication in luarocks, opm 40

Slide 173

Slide 173 text

Wiola: Publication in luarocks, opm 40 • luarocks: there is one part of the dependencies, there is no other:

Slide 174

Slide 174 text

Wiola: Publication in luarocks, opm 40 • luarocks: there is one part of the dependencies, there is no other: - lua-resty-websocket

Slide 175

Slide 175 text

Wiola: Publication in luarocks, opm 40 • luarocks: there is one part of the dependencies, there is no other: - lua-resty-websocket - lua-resty-redis

Slide 176

Slide 176 text

Wiola: Publication in luarocks, opm 40 • luarocks: there is one part of the dependencies, there is no other: - lua-resty-websocket - lua-resty-redis ✓ rapidjson

Slide 177

Slide 177 text

Wiola: Publication in luarocks, opm 40 • luarocks: there is one part of the dependencies, there is no other: - lua-resty-websocket - lua-resty-redis ✓ rapidjson ✓ lua-resty-hmac

Slide 178

Slide 178 text

Wiola: Publication in luarocks, opm 40 • luarocks: there is one part of the dependencies, there is no other: - lua-resty-websocket - lua-resty-redis ✓ rapidjson ✓ lua-resty-hmac ✓ lua-messagepack

Slide 179

Slide 179 text

Wiola: Publication in luarocks, opm 40 • luarocks: there is one part of the dependencies, there is no other: - lua-resty-websocket - lua-resty-redis ✓ rapidjson ✓ lua-resty-hmac ✓ lua-messagepack • opm (OpenResty Package Manager): accurate to "reverse":

Slide 180

Slide 180 text

Wiola: Publication in luarocks, opm 40 • luarocks: there is one part of the dependencies, there is no other: - lua-resty-websocket - lua-resty-redis ✓ rapidjson ✓ lua-resty-hmac ✓ lua-messagepack • opm (OpenResty Package Manager): accurate to "reverse": ✓ lua-resty-websocket

Slide 181

Slide 181 text

Wiola: Publication in luarocks, opm 40 • luarocks: there is one part of the dependencies, there is no other: - lua-resty-websocket - lua-resty-redis ✓ rapidjson ✓ lua-resty-hmac ✓ lua-messagepack • opm (OpenResty Package Manager): accurate to "reverse": ✓ lua-resty-websocket ✓ lua-resty-redis

Slide 182

Slide 182 text

Wiola: Publication in luarocks, opm 40 • luarocks: there is one part of the dependencies, there is no other: - lua-resty-websocket - lua-resty-redis ✓ rapidjson ✓ lua-resty-hmac ✓ lua-messagepack • opm (OpenResty Package Manager): accurate to "reverse": ✓ lua-resty-websocket ✓ lua-resty-redis - rapidjson

Slide 183

Slide 183 text

Wiola: Publication in luarocks, opm 40 • luarocks: there is one part of the dependencies, there is no other: - lua-resty-websocket - lua-resty-redis ✓ rapidjson ✓ lua-resty-hmac ✓ lua-messagepack • opm (OpenResty Package Manager): accurate to "reverse": ✓ lua-resty-websocket ✓ lua-resty-redis - rapidjson ✓ lua-resty-hmac

Slide 184

Slide 184 text

Wiola: Publication in luarocks, opm 40 • luarocks: there is one part of the dependencies, there is no other: - lua-resty-websocket - lua-resty-redis ✓ rapidjson ✓ lua-resty-hmac ✓ lua-messagepack • opm (OpenResty Package Manager): accurate to "reverse": ✓ lua-resty-websocket ✓ lua-resty-redis - rapidjson ✓ lua-resty-hmac - lua-messagepack

Slide 185

Slide 185 text

Useful links about WAMP 41

Slide 186

Slide 186 text

Useful links about WAMP • WAMP main site: http://wamp-proto.org/ • WAMP spec on github: github.com/wamp-proto/wamp-proto • Mailing list: https://groups.google.com/forum/#!forum/wampws • Wiola: https://github.com/KSDaemon/wiola • Loowy: https://github.com/KSDaemon/Loowy • Wampy.js: https://github.com/KSDaemon/wampy.js • Wiola docker image: https://hub.docker.com/r/421p/wiola/ • Crossbar Router: https://crossbar.io/ и https://demo.crossbar.io/ 41

Slide 187

Slide 187 text

WAMP: Conclusion 42

Slide 188

Slide 188 text

WAMP: Conclusion • A simple and open Protocol 42

Slide 189

Slide 189 text

WAMP: Conclusion • A simple and open Protocol • RPC and PubSub in one transport/protocol 42

Slide 190

Slide 190 text

WAMP: Conclusion • A simple and open Protocol • RPC and PubSub in one transport/protocol • Any transport and serialization 42

Slide 191

Slide 191 text

WAMP: Conclusion • A simple and open Protocol • RPC and PubSub in one transport/protocol • Any transport and serialization • Allows you to build distributed applications with loosely coupled components 42

Slide 192

Slide 192 text

WAMP: Conclusion • A simple and open Protocol • RPC and PubSub in one transport/protocol • Any transport and serialization • Allows you to build distributed applications with loosely coupled components • There are implementations in many languages 42

Slide 193

Slide 193 text

WAMP: Conclusion • A simple and open Protocol • RPC and PubSub in one transport/protocol • Any transport and serialization • Allows you to build distributed applications with loosely coupled components • There are implementations in many languages • Open source 42

Slide 194

Slide 194 text

WAMP: Conclusion • A simple and open Protocol • RPC and PubSub in one transport/protocol • Any transport and serialization • Allows you to build distributed applications with loosely coupled components • There are implementations in many languages • Open source • A small but friendly community 42

Slide 195

Slide 195 text

WAMP: Conclusion 43

Slide 196

Slide 196 text

WAMP: Conclusion • Useful architectural solution 43

Slide 197

Slide 197 text

WAMP: Conclusion • Useful architectural solution • A great option for your IoT project! (IMHO: better than MQTT) 43

Slide 198

Slide 198 text

WAMP: Conclusion • Useful architectural solution • A great option for your IoT project! (IMHO: better than MQTT) • Try WAMP: 43

Slide 199

Slide 199 text

WAMP: Conclusion • Useful architectural solution • A great option for your IoT project! (IMHO: better than MQTT) • Try WAMP: • Already have nginx/openresty? — try Wiola (bit.ly/wiola-router) 43

Slide 200

Slide 200 text

WAMP: Conclusion • Useful architectural solution • A great option for your IoT project! (IMHO: better than MQTT) • Try WAMP: • Already have nginx/openresty? — try Wiola (bit.ly/wiola-router) • Are you using a docker? 43

Slide 201

Slide 201 text

WAMP: Conclusion • Useful architectural solution • A great option for your IoT project! (IMHO: better than MQTT) • Try WAMP: • Already have nginx/openresty? — try Wiola (bit.ly/wiola-router) • Are you using a docker? • docker pull 421p/wiola 43

Slide 202

Slide 202 text

WAMP: Conclusion • Useful architectural solution • A great option for your IoT project! (IMHO: better than MQTT) • Try WAMP: • Already have nginx/openresty? — try Wiola (bit.ly/wiola-router) • Are you using a docker? • docker pull 421p/wiola • docker pull crossbario/crossbar 43

Slide 203

Slide 203 text

WAMP: Conclusion • Useful architectural solution • A great option for your IoT project! (IMHO: better than MQTT) • Try WAMP: • Already have nginx/openresty? — try Wiola (bit.ly/wiola-router) • Are you using a docker? • docker pull 421p/wiola • docker pull crossbario/crossbar • WAMP client for every taste and color (wamp-proto.org/implementations/) 43

Slide 204

Slide 204 text

Thank you for attention! And your questions :) 44 Konstantin Burkalev • Mail: [email protected] • Twitter: @KSDaemon • GitHub: KSDaemon • Blog: blog.ksdaemon.ru • SDCast: sdcast.ksdaemon.ru