38
Vasiliy Soshnikov, Sr. Software Engineer, Mail.Ru Group Master-Master Replication and Scaling of an Application between each of the IoT-Devices and the Cloud

Master-Master Replication and Scaling of an Application Between Each of the IoT Devices and the Cloud

Embed Size (px)

Citation preview

Vasiliy Soshnikov, Sr. Software Engineer, Mail.Ru Group

Master-Master Replication and Scaling of an Application between each of the IoT-Devices

and the Cloud

Agenda

• General idea

• An implementation

• Result

General idea

Everything are sync

App-server

IoT-device #1

IoT-device #N

Internet World

MoreIoT-devices

User

Requirements

• The system should sync data between each IoT-devices

• The system should getting data from IoT-devices

• The system should sync data IoT-devices and the cloud

User / App server

App server

HTTP / HTTPS / WebSockets Internet

Internet / IoT devices

App-server

IoT-device #1

IoT-device #2

InternetWorld

?

Internet / IoT devices

App-server

IoT-device #1

IoT-device #2

InternetWorld

MQTT

Internet / IoT devices

App-server

IoT-device #1

IoT-device #2

InternetWorld

Even HTTP(S)

Internet / IoT devices

App-server

IoT-device #1

IoT-device #2

InternetWorld

Some protocols

Internet / IoT devices

App-server

IoT-device #1

IoT-device #2

InternetWorld

Async replication!

Async replication

• Replication - everywhere we have the same dataset!

• Most of databases include Replication

Few words about databases

Databases

• Sqlite - no replication, no concurrent access

• Redis - only M-S replication

• MySQL and PgSQL - they to heavy for the small device

• Tarantool - M-M replication, M-S replication

• Or any DB with M-M replication

An implementation

Problems with Tarantool

Problems with Tarantool

• Didn’t work under the armv7

• Didn’t work under the 32-bit (only 64-bit)

Solved!

• Use toolchain files for CMake.

• Don’t use unsigned and other types with specified sizes; the libc has concrete types, like uint32_t.

• Port auto-test, you should expect that your auto-test may be executed under a IoT-device.

IoT-device with 6LoWPAN / LoRaWAN

6LoWPAN / LoRaWAN

IoT-device #1

IoT-device #N

World

MoreIoT-devices

Getaway

Radio Waves

Gateway

• MIPS-based

• WAN-antenna on board

• 6lbr-gateway software installed

• 6lbr-gateway converts the radio-waves into the IPv6-package and back.

6lbr

Link: cetic.github.io/6lbr/

or tty

6lbr-application

• 6lbr-application has TCP/IP stack

• 6lbr-application works with any tty

• 6lbr-application doesn’t work with MQTT. Sad!

Few words about 6lbr-application

6lbr-application

• It has complex thread model

• It has complex memory model

Main loop of an application

What is next?

• 6lbr-gateway gives a possibility to create mesh-network

• 6lbr-gateway and Tarantool tied via MQTT-broker.

• But! Tarantool doesn’t work with MQTT!

Tarantool / MQTT

MQTT-library

• libmosquitto - simple & portable & nice code!

• mosquitto - simple & fast MQTT-broker

Link: mosquitto.org/man/libmosquitto-3.html

Looping / Tarantool Fibers

Link: github.com/tarantool/mqtt

Example

6lbr-gateway / MQTT / Async M-M Replication

Result

App-server

IoT-device #1

IoT-device #N

Internet

Async M-M replication

6lbr-gateway

MQTT over UART

MQTT over UART

User

Inside devices

Devices for prototyping

TODO the photo of GETAWAY

Gateway

Relay

Sensor

Relay

IoT-device

References

Tarantool

github.com/tarantool

6lbr

github.com/cetic/6lbr

Examples / My experiments

github.com/dedok/tarantool-on-edison

Questions & My contacts

facebookfacebook.com/vasiliy.soshnikov

[email protected], [email protected]

github github.com/dedok