Speed Up Your Existing Relational Databases with Hazelcast and Speedment

Preview:

Citation preview

SPEEDUP YOUR EXISTING RELATIONAL DATABASES Per-Åke Minborg

www.speedment.com

PROBLEM

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

• The amount of data is increasing every day

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

THE JAVA DEVELOPER BEHIND THE STEERING WHEEL!

• The hot new solution

• Fast to develop applications

• Extreme database speed

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

Database

Hazelcast

Hazelcast Application

Hazelcast Application

Hazelcast Application

THE SHARED DATABASE CHALLENGE

Database

Hazelcast

Hazelcast Application3:rd Party Application

3:rd Party Application

3:rd Party Application

Hazelcast Application

Hazelcast Application

THE SHARED DATABASE CHALLENGE

Database

Speedment

Hazelcast

Hazelcast Application3:rd Party Application

3:rd Party Application

3:rd Party Application

Hazelcast Application

Hazelcast Application

THE SHARED DATABASE CHALLENGE

Database Speedment

HazelcastNode

HazelcastNode

HazelcastNode

HazelcastNode

INSERTUPDATEDELETE

OVERVIEW

JVM

SPEEDMENT TECHNOLOGY

MOV

CQRS

In-Memory

Copy

Relational

Database

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

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");

HOW TO INSTALL

• Download software

• Unzip distribution file

• Start scripts in ”bin” directory

WORK FLOW

1. Database 2. Speedment GUI 3. IDE

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.

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 | |

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

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.

HOW DO YOU USE IT?

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

1) CONNECT TO YOUR EXISTING SQL DB…

…AND IT IS AUTOMATICALLY ANALYZED

2) PUSH PLAY

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

MOBILE NETWORK OPERATOR

• Oracle database with:• One active

• One hot standby

• One cool standby

• More than 100 GB data

MOBILE NETWORK OPERATOR

Oracle

Appl.Server

Oracle

Oracle

Appl.Server

Appl.Server

LoadSharer

Off-site

Users

MOBILE NETWORK OPERATOR

HazelcastNode

HazelcastNode

HazelcastNode

HazelcastNode

Speedment

Oracle

Oracle

Oracle

Off-site

Appl.Server

Appl.Server

Appl.Server

LoadSharer

Users

>100 times faster

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)

DB

SALES ORGANIZATION

DB

DB

1

2

8

.

.

.

.

.

HQmail

mail

mail

MySQL

SALES ORGANIZATION

Speedment

HZHZ

HZHZ

MySQL

Postgress

1

2

8

.

.

.

.

.

Speedment

Speedment

MySQL Speedment

HQVPN

VPN

VPN

Improved Business intelligence

POWER GRID OPERATOR

• 1 200 transmission nodes

• 1 300 000 homes

• Reports meter status each hour

• Each report contains several measurements

Users

POWER GRID OPERATOR

DB

1,3 M meters

Grid

Internet Writer

x1000 TPS

DB

Users

1,3 M meters

POWER GRID OPERATOR

Grid

Internet Writer

Speedment

HZHZ

HZHZ

JSON

>100 times faster

THANKS!

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

• Twitter: @Pminborg

• Mail: minborg@speedment.org

• Blog: minborgsjavapot.blogspot.com

Recommended