Speed Up Your Existing Relational Databases with Hazelcast and Speedment

32
SPEEDUP YOUR EXISTING RELATIONAL DATABASES Per-Åke Minborg www.speedment.com

Transcript of Speed Up Your Existing Relational Databases with Hazelcast and Speedment

Page 1: Speed Up Your Existing Relational Databases with Hazelcast and Speedment

SPEEDUP YOUR EXISTING RELATIONAL DATABASES Per-Åke Minborg

www.speedment.com

Page 2: Speed Up Your Existing Relational Databases with Hazelcast and Speedment

PROBLEM

• Long response times is the most common IT problem at work

• The amount of data is increasing every day

Page 3: Speed Up Your Existing Relational Databases with Hazelcast and Speedment

SOLUTIONS

New Ground

Application developer

HW supplier

DBA

Architect

Carpenter

Painter

Ground

Buy faster better

more HW -expensive

Optimize database –minor effect

Extreme performance –migration project

Page 4: Speed Up Your Existing Relational Databases with Hazelcast and Speedment

THE JAVA DEVELOPER BEHIND THE STEERING WHEEL!

• The hot new solution

• Fast to develop applications

• Extreme database speed

Page 5: Speed Up Your Existing Relational Databases with Hazelcast and Speedment

TECHNOLOGY EVOLUTION

• Memory size exponentially doubles each 18:th month

• The number of CPU-cores [N] is increasing moderately

• Performance per CPU-core [P(N)] is increasing moderately

• P = N*P(N) is increasing exponentially

• "Cloud" deployment is popular

Page 6: Speed Up Your Existing Relational Databases with Hazelcast and Speedment

Database

Hazelcast

Hazelcast Application

Hazelcast Application

Hazelcast Application

THE SHARED DATABASE CHALLENGE

Page 7: Speed Up Your Existing Relational Databases with Hazelcast and Speedment

Database

Hazelcast

Hazelcast Application3:rd Party Application

3:rd Party Application

3:rd Party Application

Hazelcast Application

Hazelcast Application

THE SHARED DATABASE CHALLENGE

Page 8: Speed Up Your Existing Relational Databases with Hazelcast and Speedment

Database

Speedment

Hazelcast

Hazelcast Application3:rd Party Application

3:rd Party Application

3:rd Party Application

Hazelcast Application

Hazelcast Application

THE SHARED DATABASE CHALLENGE

Page 9: Speed Up Your Existing Relational Databases with Hazelcast and Speedment

Database Speedment

HazelcastNode

HazelcastNode

HazelcastNode

HazelcastNode

INSERTUPDATEDELETE

OVERVIEW

Page 10: Speed Up Your Existing Relational Databases with Hazelcast and Speedment

JVM

SPEEDMENT TECHNOLOGY

MOV

CQRS

In-Memory

Copy

Relational

Database

Page 11: Speed Up Your Existing Relational Databases with Hazelcast and Speedment

REFLECTS ALL DATA WITH HAZELCAST

Insertssql> insert into employees (emp_no, birth_date, first_name, last_name, gender, hire_date)

values (10001, '1953-09-02', 'Georgi', 'Facello', 'M', '1986-06-26');

10001 -> Employees { "emp_no": 10001, "birth_date": "1953-09-02", "first_name": "Georgi", "last_name": "Facello", "gender": "M", "hire_date": "1986-06-26"}

Updatessql> update employees set first_name="Georgi2" where emp_no=10001;

10001 -> Employees { "emp_no": 10001, "birth_date": "1953-09-02", "first_name": "Georgi2", "last_name": "Facello", "gender": "M", "hire_date": "1986-06-26"}

Deletessql> delete from employees where emp_no = 10001;

10001 -> null

Page 12: Speed Up Your Existing Relational Databases with Hazelcast and Speedment

WORKS WITH TRANSACTIONS

SQL> START TRANSACTION;

update employees

set first_name="Duangkaew“

where emp_no=10010;

update salaries

set salary=salary+10

where id=12322;

COMMIT;

// Backing hazelcast maps are updated atomically

Employees emp = employeesMap.get("10001");

Salaries sal = salaryMap.get("12322");

Page 13: Speed Up Your Existing Relational Databases with Hazelcast and Speedment

HOW TO INSTALL

• Download software

• Unzip distribution file

• Start scripts in ”bin” directory

Page 14: Speed Up Your Existing Relational Databases with Hazelcast and Speedment

WORK FLOW

1. Database 2. Speedment GUI 3. IDE

Page 15: Speed Up Your Existing Relational Databases with Hazelcast and Speedment

GENERATED CODE

• Everything you will need including POJOs and serialization factories are generated automatically.

• Just add 4 lines of code in your Hazelcast application and you are good to go.

Page 16: Speed Up Your Existing Relational Databases with Hazelcast and Speedment

DATABASE TABLE

mysql> describe employees;

+------------+---------------+------+-----+---------+----------------+

| Field | Type | Null | Key | Default | Extra |

+------------+---------------+------+-----+---------+----------------+

| emp_no | int(11) | NO | PRI | NULL | auto_increment |

| birth_date | date | NO | | NULL | |

| first_name | varchar(14) | NO | | NULL | |

| last_name | varchar(16) | NO | | NULL | |

| gender | enum('M','F') | NO | | NULL | |

| hire_date | date | NO | | NULL | |

+------------+---------------+------+-----+---------+----------------+

Page 17: Speed Up Your Existing Relational Databases with Hazelcast and Speedment

POJO REPRESENTING A ROW

public class Employees extends Struct<Employees> implements

IdentifiedDataSerializable {

private Integer empNo;

private Date birthDate;

private String firstName;

private String lastName;

private String gender;

private Date hireDate;

// Accessors, serialization, deserialization, etc.

Page 18: Speed Up Your Existing Relational Databases with Hazelcast and Speedment

HOW DO YOU USE IT?

“Easy as 1, 2, 3...”

Page 19: Speed Up Your Existing Relational Databases with Hazelcast and Speedment

1) CONNECT TO YOUR EXISTING SQL DB…

Page 20: Speed Up Your Existing Relational Databases with Hazelcast and Speedment

…AND IT IS AUTOMATICALLY ANALYZED

Page 21: Speed Up Your Existing Relational Databases with Hazelcast and Speedment

2) PUSH PLAY

Page 22: Speed Up Your Existing Relational Databases with Hazelcast and Speedment

Work as you are used to, just add 4 lines of code in your startup class

Config hcConfig = new Config();

// Add optimized serialization Factories for Hazelcast that are generated automatically

SpeedmentHazelcastConfig.addTo(hcConfig);

HazelcastInstance hcInstance = Hazelcast.newHazelcastInstance(hcConfig);

// Tell Speedment what Hazelcast instance to use

ProjectManager.getInstance().putProperty(HazelcastInstance.class, hcInstance);

// Automatically build all Database metadata (e.g. Schema, Tables and Columns)

new TreeBuilder().build();

// Load selected data from the database into the Hazelcast maps and start tracking DB

ProjectManager.getInstance().init();

3) START CODING WITH HAZELCAST

Page 23: Speed Up Your Existing Relational Databases with Hazelcast and Speedment

MOBILE NETWORK OPERATOR

• Oracle database with:• One active

• One hot standby

• One cool standby

• More than 100 GB data

Page 24: Speed Up Your Existing Relational Databases with Hazelcast and Speedment

MOBILE NETWORK OPERATOR

Oracle

Appl.Server

Oracle

Oracle

Appl.Server

Appl.Server

LoadSharer

Off-site

Users

Page 25: Speed Up Your Existing Relational Databases with Hazelcast and Speedment

MOBILE NETWORK OPERATOR

HazelcastNode

HazelcastNode

HazelcastNode

HazelcastNode

Speedment

Oracle

Oracle

Oracle

Off-site

Appl.Server

Appl.Server

Appl.Server

LoadSharer

Users

>100 times faster

Page 26: Speed Up Your Existing Relational Databases with Hazelcast and Speedment

SALES ORGANIZATION

• HQ in Sweden

• Local national offices in 8 other countries

• 3 to 25 shops in each country

• Most national offices have their own database

• Extract, Transform and Load (ETL)

Page 27: Speed Up Your Existing Relational Databases with Hazelcast and Speedment

DB

SALES ORGANIZATION

DB

DB

1

2

8

.

.

.

.

.

HQmail

mail

mail

Page 28: Speed Up Your Existing Relational Databases with Hazelcast and Speedment

MySQL

SALES ORGANIZATION

Speedment

HZHZ

HZHZ

MySQL

Postgress

1

2

8

.

.

.

.

.

Speedment

Speedment

MySQL Speedment

HQVPN

VPN

VPN

Improved Business intelligence

Page 29: Speed Up Your Existing Relational Databases with Hazelcast and Speedment

POWER GRID OPERATOR

• 1 200 transmission nodes

• 1 300 000 homes

• Reports meter status each hour

• Each report contains several measurements

Page 30: Speed Up Your Existing Relational Databases with Hazelcast and Speedment

Users

POWER GRID OPERATOR

DB

1,3 M meters

Grid

Internet Writer

x1000 TPS

Page 31: Speed Up Your Existing Relational Databases with Hazelcast and Speedment

DB

Users

1,3 M meters

POWER GRID OPERATOR

Grid

Internet Writer

Speedment

HZHZ

HZHZ

JSON

>100 times faster

Page 32: Speed Up Your Existing Relational Databases with Hazelcast and Speedment

THANKS!

• GitHub: https://github.com/speedment/speedment-orm

• Twitter: @Pminborg

• Mail: [email protected]

• Blog: minborgsjavapot.blogspot.com