Presentation is loading. Please wait.

Presentation is loading. Please wait.

Nam Nguyen Software Engineer Caucho Technology, Inc.

Similar presentations


Presentation on theme: "Nam Nguyen Software Engineer Caucho Technology, Inc."— Presentation transcript:

1 Nam Nguyen Software Engineer Caucho Technology, Inc.
Baratine in Practice Date: Location: San Diego JUG Nam Nguyen Software Engineer Caucho Technology, Inc.

2 Baratine in Practice Download Install Our - Multiple counters - implement an Type of services chart Partitioning and clustering

3 Task: Baratine quick start - Download - Install - Our first service

4 public class CounterServiceImpl { private long _id; private long _counter; public long get() return _counter; public long incrementAndGet() { return ++_counter; public long decrementAndGet() { return --_counter; public long addAndGet(long value) { _counter = _counter + value;

5 jonathan hughes optiminsight
HTTP Polling HTTP REST WebSocket Java INBOX OUTBOX public class CounterServiceImpl { private long _id; private long _counter; public long get() return _counter; public long incrementAndGet() { return ++_counter; public long decrementAndGet() { return --_counter; public long addAndGet(long value) { _counter = _counter + value; JOURNAL KEY-VALUE DB (internal)

6 What You Get + Insane low-latency concurrent performance
assign thread 1. incrementAndGet() 2. incrementAndGet() 3. addAndGet() 4. decrementAndGet() 5. incrementAndGet() 6. incrementAndGet() 7. ... NO BLOCKING / LOCKING !  CPU cache stays hot (for both data and instructions) CPU core uninterrupted during batch no context switching no pausing thread screams through entire batch Batch A Batch B Instead of the CPU core spending time in the operating system’s scheduling code, or the queue blocking code, the core spends all its time in the code that matters the most: your service code.

7 Batch Programming assign thread @BeforeBatch 1 incrementAndGet() 2. addAndGet() 3. addAndGet() 4. decrementAndGet() 5. incrementAndGet() 6. incrementAndGet() @AfterBatch - flush writes 7. ...  Leave expensive operations to be executed at the end of the batch. Inbox is empty at this point

8 Performance Characteristics
Requests per Second Baratine Batch Size / Clients

9 Performance Characteristics
ServiceA to ServiceB within the same JVM Batch Size / Clients Requests per Second Baratine If same JVM, get a magnitude better performance. e.g. analytics or reporting service that co-hosted in the same JVM as your other services. Like deploying a job to Hadoop and letting it run among your data.

10 Reliable to Batch  Safe to process in batches. @OnCheckpoint
assign thread @BeforeBatch 1 incrementAndGet() 2. addAndGet() 3. addAndGet() 4. decrementAndGet() 5. incrementAndGet() 6. incrementAndGet() @AfterBatch - flush writes 7. ...  Safe to process in batches. @OnCheckpoint Journaling

11 Putting it All Together
Freed to operate in memory safely! ▲ Operational Data What is Operational Data? Instead of having data stored in some external database, it is owned and stored in the service itself where it’s being used and modified. The service has ownership of its own data. The data stays with the service, within the same JVM, even within the same object instance. It’s true object-oriented programming in the finest sense where the object encapsulates both data and logic.

12 Sounds like a lot of magic is going on.
@Journal @ResourceService(“public:///counter/{_id}”) public class CounterServiceImpl { private long _id; private long _counter; public long get() return _counter; } @Modify public long incrementAndGet() { return ++_counter; public long decrementAndGet() { return --_counter; public long addAndGet(long value) { _counter = _counter + value; What do you get with a service so simple? Your service is operating like a database, but with logic and data working together seamlessly. Sounds like a lot of magic is going on.

13 Warning: hardcore! @Service
Barebones service, basis Singleton, only one instance within a JVM - - No automatic restore - No automatic paging - No automatic checkpointing - No automatic query support - No automatic partitioning Warning: hardcore!

14 @Service Less magic: you have fine-grained control

15 Task: implement a logging service with a @Service

16 @Workers with a thread-pool acting on the inbox. Example: hibernate, SAP, MySQL, legacy, integration - Does not fully benefit from batching - Not single-threaded + Can block + Multi-threaded

17 Task: implement a @Workers @Service

18 Types of Services Annotation: @ResourceService @Service @Workers
Batching ✓* Journaling Checkpointing Paging Partitioning Resource ID’s Search Threaded-ness single multi Can Block? Performance ★★★☆ ★★★★ ★☆☆☆ (manual)

19 Partitioning and Clustering
/auction/111 /auction/444 /auction/999 /auction/222 /auction/555 /auction/888 /auction/000 /auction/333 /auction/666 /auction/777 Resources are partitioned by its service URL and ID

20 State of Baratine GPL Been in active development for over 2 years v0.8.3 (alpha) (alpha) Thank you! stealth <

21 The End Q and A


Download ppt "Nam Nguyen Software Engineer Caucho Technology, Inc."

Similar presentations


Ads by Google