New Real-time Applications PhD Peter Idestam-Almquist Starcounter AB - - PowerPoint PPT Presentation

new real time applications
SMART_READER_LITE
LIVE PREVIEW

New Real-time Applications PhD Peter Idestam-Almquist Starcounter AB - - PowerPoint PPT Presentation

NewSQL Database for New Real-time Applications PhD Peter Idestam-Almquist Starcounter AB New real time applications Millions of simultaneous online users. High degree of concurrency. Interactive applications (95% reads; 5% writes). 2


slide-1
SLIDE 1

NewSQL Database for New Real-time Applications

PhD Peter Idestam-Almquist Starcounter AB

slide-2
SLIDE 2

New real time applications

2

Millions of simultaneous online users. High degree of concurrency. Interactive applications (95% reads; 5% writes).

slide-3
SLIDE 3

Starcounter database

We claim you can run the database of a large webshop like amazon.com on a single

  • ff-the-shelf server using Starcounter.

Old products: slow, complex, expensive. The new generation: easy, fast, game changing.

3

slide-4
SLIDE 4

Outline

Positioning Consistency Performance Code examples

4

slide-5
SLIDE 5

Database landscape

5

Matthew Aslett, The 451 Group

slide-6
SLIDE 6

NoSQL and NewSQL

NoSQL:

New breed of non-relational database products; Rejections of fixed table schema and join operations; Designed to meet scalability requirements of distributed architectures; And/or schema-less data management requirements. 6

NewSQL:

New breed of relational database products; Retain SQL and ACID; Designed to meet scalability requirements of distributed architectures; Or improve performance so horizontal scalability is no longer a necessity.

Matthew Aslett, The 451 Group

slide-7
SLIDE 7

Data management challenge

You have: big data volumes, many simultaneous online users (updating data). You want: high performance (throughput and latency), consistent data.

7

slide-8
SLIDE 8

Your alternatives

8

slide-9
SLIDE 9

Outline

Positioning Consistency Performance Code examples

9

slide-10
SLIDE 10

ACID transactions

ACID transactions guarantee consistent data: Atomicity - either entire transaction or nothing; Consistency - valid state before and after

transaction;

Isolation - no transaction interfers with another

transaction;

Durability - committed transactions will remain after

crash or power loss.

10

slide-11
SLIDE 11

Isolation levels

Different isolation levels to trade off between performance and consistency: Read uncommitted - dirty reads; Read committed - non-repeatable reads; Repeatable reads - phantom reads; Serializable (required for ACID)

  • as executing transactions sequentially;
  • often relaxed to snapshot isolation.

11

slide-12
SLIDE 12

Scale out and global consistency

12

Throughput Database nodes Distributed transactions (two-phase commits) gives (high degree

  • f) global consistency, but do not scale.
slide-13
SLIDE 13

Scale out and local consistency

13

Horizontal scaling (shared-nothing) scales linearly, but gives no global consistency (only local consistency). Throughput Database nodes

slide-14
SLIDE 14

CAP theorem (Brewer)

14

A distributed system can satisfy two but not three out of: Consistency - all nodes see the same data at the

same time;

Availability - every request recieves a response

whether it succeeded or failed;

Partition tolerance - operates despite of message

loss or failure of part of the system.

slide-15
SLIDE 15

Our conclusion

15

You cannot achieve both high performance and consistency by scaling-out. To achieve both high performance and consistency you should:

Scale-in - execute all transactions in RAM (performance) on the same computer (consistency); Scale-up - get a powerful multi-core server with a lot

  • f RAM (performance).
slide-16
SLIDE 16

Do I need ACID?

16

When dealing with business critical data like stock quantities or money. For multi-user applications transactional conflicts will occur and need to be managed by:

database (DBMS), application (hard for developers), end user: "Sorry we have just sold you a product we already have sold to someone else".

slide-17
SLIDE 17

Outline

Positioning Consistency Performance Code examples

17

slide-18
SLIDE 18

Application performance

18

For the performance of an application the interaction between the application and the database is crucial. Our invention: VMDBMS, which integrates the application runtime (virtual machine - VM) and the database management system (DBMS).

slide-19
SLIDE 19

Traditional DBMS

Data is copied back and forth between the application (heap) and the database. Business objects store temporary local copies of the data.

RAM

DBMS cache Object heap Application code Application code

19

slide-20
SLIDE 20

Our invention - VMDBMS

Data is not moved between the database and the application (heap). Data resides only in the database, and the business

  • bjects have no local copies of the data.

RAM

DBMS Object heap Application code Application code

20

slide-21
SLIDE 21

Starcounter read performance (SQL)

21

Transactions per second CPU cores 2 4 6 8 10 12 1,000,000 2,000,000 3,000,000 4,000,000 5,000,000 6,000,000

slide-22
SLIDE 22

Starcounter read performance (SQL)

22

500,000 read-only ACID transactions per second and core for SQL queries. Scales almost linearly on the number of cores.

Int32 productId; Int32 quantity; ... Db.Transaction(delegate { Product product = Db.SQL("select p from Product p where p.Id = ?", productId).First; quantity = product.Quantity; })

slide-23
SLIDE 23

Starcounter read performance (ref)

23

You can traverse four millions of nodes in an

  • bject graph in a second (using one core).

Node cursor; ... Db.Transaction(delegate { while (cursor.Next != null) { cursor = cursor.Next; } })

slide-24
SLIDE 24

Starcounter write performance

24

Transactions per second CPU cores 1 2 3 4 5 6 100,000 200,000 300,000 400,000 500,000 600,000

slide-25
SLIDE 25

Starcounter write performance

25

100,000 read-write ACID transactions per second on one core for SQL queries. Do not scale on the number of cores. Max 250,000 ACID transactions per second.

Int32 productId; ... Db.Transaction(delegate { Product product = Db.SQL("select p from Product p where p.Id = ?", productId).First; product.Quantity = product.Quantity - 1; })

slide-26
SLIDE 26

A very large webshop

26

1 billions of orders per year. 10 billions of write transactions (400/s). 200 billions of read transactions (8,000/s). 54 GB order data per year. Intel Xeon, 32 cores, 1 TB RAM, 50000 USD.

slide-27
SLIDE 27

Outline

Positioning Consistency Performance Code examples

27

slide-28
SLIDE 28

Starcounter .NET object API

Database schema (”create table”): class definitions inheriting Starcounter.Entity. Create object (”insert”): native ”new” operator. Modify object (”update”): native assignment operator (”=”). Delete object (”delete”): use object method Delete(). Query objects (”select”): SQL(”select ...”). 28

slide-29
SLIDE 29

Database schema

using Starcounter; public class Employee : Entity { public string Name; public Nullable<DateTime> HireDate; public decimal Salary; public Department Department; public Employee Manager; ... }

29

slide-30
SLIDE 30

Create object

public class Employee : Entity { ... public Employee() { } } ... Employee e = new Employee();

30

slide-31
SLIDE 31

Modify object

... Department d = new Department(); ... Employee e = new Employee(); e.Name = ”John”; e.HireDate = null; e.Salary = 20000; e.Department = d;

31

slide-32
SLIDE 32

Delete object

... Employee e = new Employee(); e.Name = ”John”; e.HireDate = null; e.Salary = 20000; e.Department = d; e.Delete();

32

slide-33
SLIDE 33

Starcounter SQL

Starcounter SQL follows SQL92 standard Object references: SELECT e FROM Employee e Path expressions: SELECT e.Name, e.Department.Name FROM Employee e Compare to: SELECT e.Name, d.Name FROM Employee e JOIN Department d ON e.DepartmentId = d.Id

33

slide-34
SLIDE 34

SQL in code

string query = ”SELECT e FROM Employee e”; foreach (Employee emp in Db.SQL(query)) emp.PrintCV(); string query = ”SELECT e FROM Employee e WHERE e.FirstName = ?”; Employee emp = Db.SQL(query, ”John”).First; emp.PrintCV();

34

slide-35
SLIDE 35

One-to-many relations

public class Employee : Entity { public Employee Manager; public IEnumerable Staff { get { string query = ”SELECT e FROM Employee e WHERE e.Manager = ?”; return Db.SQL(query, this); } } }

35

slide-36
SLIDE 36

Transactions

Db.Transaction(delegate() { string query = ”SELECT e FROM Employee e WHERE e.Name = ?”; Employee emp = Db.SQL(query, ”John”).First; if (emp != null) emp.Name = ”Bill”; });

36

slide-37
SLIDE 37

Starcounter database

Transactional database (OLTP). ACID compliant. High performance (500,000 TPS per core). Robust (previous versions used in production for 5 years). Reliable (replication and full checkpoint recovery). In-memory (transactions secured on disk). SQL query support. Native (.NET) object API. New invention: VMDBMS. 37

slide-38
SLIDE 38

Questions ?

38

More info on www.starcounter.com.