STARCOUNTER. Technical Overview

Similar documents
DOT NET Syllabus (6 Months)

Java SE7 Fundamentals

describe the functions of Windows Communication Foundation describe the features of the Windows Workflow Foundation solution

welcome to BOILERCAMP HOW TO WEB DEV

Chapter 10 Web-based Information Systems

Web Applications. Software Engineering 2017 Alessio Gambi - Saarland University

INTRODUCTION TO.NET. Domain of.net D.N.A. Architecture One Tier Two Tier Three Tier N-Tier THE COMMON LANGUAGE RUNTIME (C.L.R.)

Index LICENSED PRODUCT NOT FOR RESALE

Bonus Content. Glossary

The NoPlsql and Thick Database Paradigms

DATABASE SYSTEMS. Database programming in a web environment. Database System Course, 2016

Enterprise Software Architecture & Design

AngularJS Fundamentals

DATABASE SYSTEMS. Database programming in a web environment. Database System Course,

Developing SQL Databases

NewSQL Database for New Real-time Applications

20762B: DEVELOPING SQL DATABASES

Microsoft Developing SQL Databases

Microsoft. [MS20762]: Developing SQL Databases

DOT NET SYLLABUS FOR 6 MONTHS

SQL Server Development 20762: Developing SQL Databases in Microsoft SQL Server Upcoming Dates. Course Description.

About 1. Chapter 1: Getting started with odata 2. Remarks 2. Examples 2. Installation or Setup 2. Odata- The Best way to Rest 2

B.H.GARDI COLLEGE OF MASTER OF COMPUTER APPLICATION. Ch. 1 :- Introduction Database Management System - 1

An Introduction to JavaScript & Bootstrap Basic concept used in responsive website development Form Validation Creating templates

Help student appreciate the DBMS scope of function

Developing Applications with Java EE 6 on WebLogic Server 12c

Review. Fundamentals of Website Development. Web Extensions Server side & Where is your JOB? The Department of Computer Science 11/30/2015

Databases - Transactions

"Charting the Course... MOC C: Developing SQL Databases. Course Summary

Developing Data Access Solutions with Microsoft Visual Studio 2010

BIS Database Management Systems.

MIS Database Systems.

Application Development in JAVA. Data Types, Variable, Comments & Operators. Part I: Core Java (J2SE) Getting Started

DATABASES SQL INFOTEK SOLUTIONS TEAM

Introduction. Example Databases

Dot Net Online Training

.Net Interview Questions

The course also includes an overview of some of the most popular frameworks that you will most likely encounter in your real work environments.

2310C VB - Developing Web Applications Using Microsoft Visual Studio 2008 Course Number: 2310C Course Length: 5 Days

Introduction to Information Systems

Saikat Banerjee Page 1

Database Applications

UI Course HTML: (Html, CSS, JavaScript, JQuery, Bootstrap, AngularJS) Introduction. The World Wide Web (WWW) and history of HTML

Oracle - Developing Applications for the Java EE 7 Platform Ed 1 (Training On Demand)

J2EE Development. Course Detail: Audience. Duration. Course Abstract. Course Objectives. Course Topics. Class Format.

Batches and Commands. Overview CHAPTER

Smashing Node.JS: JavaScript Everywhere

Enterprise Web based Software Architecture & Design

FIREFLY ARCHITECTURE: CO-BROWSING AT SCALE FOR THE ENTERPRISE

MASTERS COURSE IN FULL STACK WEB APPLICATION DEVELOPMENT W W W. W E B S T A C K A C A D E M Y. C O M

Software Architecture With ColdFusion: Design Patterns and Beyond Topics Outline Prepared by Simon Horwith for CFUnderground 6

PROCE55 Mobile: Web API App. Web API.

Introduction to Web Application Development Using JEE, Frameworks, Web Services and AJAX

Orb-Weaver if the radiance of thousand suns were burst at once into the sky that might be the splendor of mighty one.

1 Copyright 2011, Oracle and/or its affiliates. All rights reserved.

Hello everyone. My name is Kundan Singh and today I will describe a project we did at Avaya Labs.

CS 498RK FALL RESTFUL APIs

An Overview of. Eric Bollens ebollens AT ucla.edu Mobile Web Framework Architect UCLA Office of Information Technology

Announcements. SQL: Part IV. Transactions. Summary of SQL features covered so far. Fine prints. SQL transactions. Reading assignments for this week

Ur/Web: A Simple Model for Programming the Web. Adam Chlipala MIT CSAIL POPL 2015 January 15, 2015

Java Enterprise Edition

Wakanda Architecture. Wakanda is made up of three main components: Wakanda Server Wakanda Studio Wakanda Client Framework

20483BC: Programming in C#

JAVA COURSES. Empowering Innovation. DN InfoTech Pvt. Ltd. H-151, Sector 63, Noida, UP

Introduction to Databases, Fall 2005 IT University of Copenhagen. Lecture 10: Transaction processing. November 14, Lecturer: Rasmus Pagh

CSE 3241: Database Systems I Databases Introduction (Ch. 1-2) Jeremy Morris

Getting started with Convertigo Mobilizer

Managing State. Chapter 13

Call: Core&Advanced Java Springframeworks Course Content:35-40hours Course Outline

Call: JSP Spring Hibernate Webservice Course Content:35-40hours Course Outline

BIG-IP Access Policy Manager : Portal Access. Version 13.0

Java SE 8 Fundamentals

Postgres Plus and JBoss

IBM Tivoli Composite Application Manager for Microsoft Applications: Microsoft.NET Framework Agent Fix Pack 13.

Lesson 1 Key-Terms Meanings: Web Connectivity of Devices and Devices Network

BIG-IP Access Policy Manager : Portal Access. Version 12.1

Notes. Submit homework on Blackboard The first homework deadline is the end of Sunday, Feb 11 th. Final slides have 'Spring 2018' in chapter title

Part VII Data Protection

Developing ASP.NET MVC Web Applications (486)

Data Management in Application Servers. Dean Jacobs BEA Systems

StorageGRID Webscale NAS Bridge Management API Guide

Q&As. Microsoft MTA Software Development Fundamentals. Pass Microsoft Exam with 100% Guarantee

Bringing Together One ASP.NET

Administration Naive DBMS CMPT 454 Topics. John Edgar 2

"Charting the Course... Mastering EJB 3.0 Applications. Course Summary

Appendix A - Glossary(of OO software term s)

Scott Meder Senior Regional Sales Manager

COSC 304 Introduction to Database Systems. Database Introduction. Dr. Ramon Lawrence University of British Columbia Okanagan

Guide to Mitigating Risk in Industrial Automation with Database

COURSE OUTCOMES OF M.Sc(IT)

SQL Server Interview Questions

Course Introduction & Foundational Concepts

Active Endpoints. ActiveVOS Platform Architecture Active Endpoints

Fast Track to Java EE

Android Essentials with Java

ASP.NET- Enterprise Applications

ReST 2000 Roy Fielding W3C

Rocking with Racket. Marc Burns Beatlight Inc

UNIT 5 - UML STATE DIAGRAMS AND MODELING

Page 1. Goals for Today" What is a Database " Key Concept: Structured Data" CS162 Operating Systems and Systems Programming Lecture 13.

Transcription:

STARCOUNTER Technical Overview

Summary 3 Introduction 4 Scope 5 Audience 5 Prerequisite Knowledge 5 Virtual Machine Database Management System 6 Weaver 7 Shared Memory 8 Atomicity 8 Consistency 9 Isolation 9 Durability 9 Queries 10 Application Layer 11 Typed JSON 12 View-Model Attaching 14 Sessions 15 Threading 15 Network Layer 16 Palindrom 17 Front-end 18 Starcounter Web Components 19 View Composition 20 Conclusion 21 2 www.starcounter.com

Summary Starcounter is a full-stack enterprise application platform. It consists of a combined in-memory database management system (DBMS), an application server and front-end libraries. It s built to make apps that are developed separately to interoperate with as little configuration, glue code, and hardware as possible. The foundation of Starcounter is the virtual machine database management system (VMDBMS) that keeps data in one place instead of moving it between the application and the database. The VMDBMS also lets different apps share data without any extra code or configuration. The next layer, the application layer, contains API s to use the VMDBMS - such as transactions, queries, and schema definitions. Also, the application layer has tools for interacting with view-models, sessions, and other utilities for building composable and interoperable web apps. The network layer is built on top of the application layer and provides real-time client-server communication with as low latency as possible. It supports network protocols such as HTTP, WebSocket, and TCP. The front-end is the presentation layer in Starcounter. It s built on a thin-client architecture. The frontend uses web standards, such as Shadow DOM and custom elements to enable different applications to share the same screen while maintaining a consistent look and feel. The VMDBMS and application layer can be used independently from the network layer and front-end. Using the VMDBMS and application layer independently makes Starcounter a fast in-memory database instead of a full-stack application platform. 3 www.starcounter.com

INTRODUCTION

Figure 0: Overview of the Starcounter architecture Scope This document focuses on Starcounter s architecture - the different components and how they are connected. It does not cover how to build Starcounter apps, tooling, security, deployment and similar aspects. This version of the document describes Starcounter as it works on version 2.4. Audience This document is for technical readers that want to understand Starcounter. This includes, but is not limited to, developers that want to get a solid background before starting development, Chief Technology Officers, software architects and others that decide about technology platforms, and existing users of Starcounter that want to improve their understanding of Starcounter fundamentals. Prerequisite Knowledge To understand everything in this document, you should know these technologies and concepts on a fundamental level: Database concepts such as transactions, ACID, and SQL Object-oriented programming The communication protocols WebSocket and Hypertext Transfer Protocol (HTTP) Web technologies such as the Document Object Model (DOM), JavaScript Object Notation (JSON), and Hypertext Markup Language (HTML) The document uses C# for code examples. The examples are simple and are meant to be understandable without knowing C#. 5 www.starcounter.com

VIRTUAL MACHINE DATABASE MANAGEMENT SYSTEM

The Virtual Machine Database Management System (VMDBMS) is a row-based relational in-memory database system based on United States Patent: 8856092. In short, the VMDBMS works like a persistent heap for a virtual machine based language, such as languages built on the.net Common Language Runtime (CLR) or the Java Virtual Machine (JVM). It currently works with C#. When an app starts, Starcounter allocates a piece of memory to the VMDBMS. Apps run inside the memory of the VMDBMS. With the apps in the VMDBMS - the VMDBMS can store objects from these apps persistently; these objects are called persistent objects. The app can access persistent objects stored in the database. It can also modify these persistent objects like any other objects. Weaver The developer defines which classes should have their instances stored persistently by decorating the classes with a particular attribute. We refer to these classes with persistent instances as database classes. The weaver, a tool that transforms the application code to work with the VMDBMS, locates the database classes during compile time. The weaver then automatically rewrites the class to call into the database engine instead of the heap. Thus, the only thing stored in the object on the heap is the identification of a persistent object in the VMDBMS that holds the data. For the developer, it looks similar to the codefirst approach in object-relational mappers such as Entity Framework where the developer defines C# classes, and the framework derives a schema from it. This is how a class looks before and after weaving: Figure 1: Database class - before weaving Figure 2: Database class - after weaving 7 www.starcounter.com

Figure 3: The VMDBMS with multiple apps After the weaver weaves the class, whenever the app use the Name property, it s retrieving or setting the value in the database and not the object on the heap. With that, persistent objects can be updated the same way as any other object. Weaved code is not visible to the developer, even if it s used by the compiler. This is by design so that the developer don t have to worry about weaving. data object, object-relational mappers are not needed. Apps running in the VMDBMS share the same memory. Thus, all apps immediately see changes to persistent objects. For example, as shown in the figure above, if app process 1 modifies the Name property of the object with the identification 123, then all other apps that also hold a reference to that object will see that the Name has changed. Shared Memory With the VMDBMS, data doesn t move between the app and the database as in traditional DBMS s. Instead, the VMDBMS modifies the data in place. Keeping data in place increases the performance of data operations, makes the memory footprint smaller and reduces the amount of application code. Since the data object is only stored in one place and the application code only has a reference to that ACID Like database management systems such as PostgreSQL and SQLite, transactions in Starcounter are atomic, consistent, isolated, and durable (ACID). Atomicity Atomicity guarantees that the DBMS either commits all or none of the operations in a transaction. Starcounter ensures atomicity by 8 www.starcounter.com

Figure 4: Optimistic concurrency control with snapshot isolation wrapping changes of one transaction within a transaction scope. The changes commit at the same time. If something interrupts the transaction before the end of the scope is reached, the VMDBMS will not commit any of the changes. Consistency A consistent DBMS ensures that all the data written to the database follow the defined constraints of the database. In Starcounter, this is solved by raising exceptions when an action that breaks the constraint is executed in a transaction, such as committing non-unique values to a field that requires unique values. The exception will in turn make the transaction roll back so that none of the changes are applied. Isolation To isolate transactions, Starcounter uses snapshot isolation with optimistic concurrency control. With snapshot isolation, all database operations in a transaction are guaranteed to see a consistent snapshot of the database. When the transaction ends, Starcounter checks if there are any conflicts between the live version of the database and the changes made in isolation. If there are no conflicts, the VMDBMS commits the changes, otherwise, the transaction starts over until the transaction is not conflicting with the live database and the VMDBMS commits the changes. Starcounter throws an exception if it takes, by default, more than 100 tries to commit the changes because of conflicts. Durability In a durable DBMS, committed changes are persistent, even if there are power failures and similar disturbance. The VMDBMS uses transaction logging to ensure durability. Transaction logging means that database operations are, on commit, written to a log file 9 www.starcounter.com

Figure 5: Log file handling on a disk. By writing database operations to a log, the VMDBMS can recreate the state of the database by going back in the log. Starcounter uses two types of log files: read-optimized and write-optimized. Writeoptimized log files are the files that the VMDBMS writes to when it commits changes. These files are optimized for high throughput. Read-optimized log files are more compact and faster to read from than write-optimized log files. A read-optimized log file is the image of the database at a specific point in time. Read-optimized log files are created from multiple write-optimized log files to save space and make it faster to load data into the VMDBMS. Asynchronous transactions in Starcounter make the log writes asynchronous. This means that other operations can still be carried out while the VMDBMS is writing to the log. Asynchronous log writes can make apps faster but also introduce extra complexity. Queries Starcounter supports a subset of the ANSI SQL-92 standard. The developer can query the database from both the Starcounter Administrator and from application code. It supports these following statements: Data Query Language (DQL): SELECT Data Definition Language (DDL): CREATE INDEX, ALTER, and DROP Data Manipulation Language (DML): DELETE To better deal with objects, Starcounter SQL supports object extensions according to Object Data Standard ODMG 3.0 (ISBN 1-55860-647-4). These extensions are object references and path expressions. This often removes the need for complicated and slow joins. 10 www.starcounter.com

APPLICATION LAYER

The application layer contains API s to use the VMDBMS, interact with view-models, sessions, and other utilities for building composable and interoperable web apps. The application layer is created to support web apps that use a model-view-view-model (MVVM) architecture. The model consists of database classes, as described in the VMDBMS section, the view-models are C# classes called Typed JSON, as described in this section, and the views are HTML documents with two-way data-bindings to the view-models, as described in the front-end section. Figure 6: The flow when a client sends a request Typed JSON Typed JSON are C# classes that are serializable to JSON. This makes it easy to work with JSON in an object-oriented way. In Starcounter, the view-models are the JSON documents that are created from, and modified with, Typed JSON. View-models are used to define the application logic and manage the application state. Typed JSON classes are primarily generated by Starcounter from a JSON file that s defined by the developer. The process of generating Typed JSON from JSON is called JSON-by-example. With JSON-by-example, the developer creates a JSON tree representing the schema of the view-model, and Starcounter creates a C# class with the same schema as the JSON tree. This JSON-by-example generates a C# class with the same name as the JSON file with three properties: Html, Name and Age. Name will, by default, be an empty string and Age will be zero. The generated Typed JSON class also has some other properties and methods that makes the view-model easier to work with. A JSON-by-example file that generates a class called PersonPage might look like this: Figure 7: A simple JSON-by-example file 12 www.starcounter.com

Figure 8: Data bindings between database classes and HTML Figure 9: View-model creation with Typed JSON Properties in Typed JSON can be bound with two-way bindings both to the view and to the model. The bindings to the model makes it possible to have a view-model represent a persistent object - whenever a property in the persistent object changes, the property in the Typed JSON object that s bound to the persistent object changes accordingly, and vice versa. The bindings to the view are explained in the Network section of this document. Typed JSON can be extended by creating a code-behind file. This code-behind handles user input and can modify the bindings between the view and view-model. The codebehind is created as a partial class definition of the automatically generated Typed JSON class. To send the data in a Typed JSON object to the client, return it from an HTTP handler. When a Typed JSON object is returned from an HTTP handler, Starcounter serializes the object to a JSON string: (see Figure 10 below) When the /person URI is called with a GET request, the method will execute the lambda that s the second argument to the method which returns a new object of type PersonPage. Starcounter will then serialize the returned object to a JSON string. This is also used to bind view-models to sessions. This allows the developer to create viewmodels declaratively without serializing or deserializing JSON - that s taken care of by the Typed JSON implementation. Figure 10: JSON serialization from HTTP handler 13 www.starcounter.com

Figure 11: View-model attaching with nested attachment rules View-Model Attaching View-model attaching is a technology that combines view-models from multiple apps that represent the same concept. View-model attaching works by specifying attachment rules that Starcounter uses to determine what concepts are related to each other when the browser makes a request. The rules are specified by the developer and registered at startup. These rules can be altered dynamically. The rules bind URIs to tokens and contexts. Tokens are either strings or database classes. Contexts are strings that denote what kind of response to return, such as icon, banner, or page. For example, a rule in one app can specify that the handler with the URI /search-result/person/{id} is tied to the token of the database class Person and the context search. Thus, whenever the browser makes a request to /search-result/ person/{id}, Starcounter checks whether there are other handlers registered that also are tied to the database class token Person and the context search. If there are other handlers with the same token and context, the responses from those handlers are attached to the response from the initially requested response and sent back to the client. View-model attaching is used together with a related technology called View composition to implement a Starcounter feature called Blending. Blending takes the views coming from multiple apps and combines them to create a common user interface with a consistent look and feel. 14 www.starcounter.com

Sessions Sessions are a way to store state that s relevant to individual users, such as view-model state and the WebSocket connection. Sessions in Starcounter are based on browser tabs and not on browser cookies like in many other application frameworks. Another difference is that Starcounter sessions are shared between apps - multiple apps running in the same code host will only have one active session at the time. Each session is bound to one WebSocket connection. This binding is created on initial page load in the app shell. The app shell is explained in the front-end section. Threading In Starcounter, all database operations and network operations, such as returning a response from an HTTP handler, have to be assigned to a thread by a Starcounter scheduler. The scheduler wraps the tasks in a context that allows them to be executed as database or network operations in Starcounter. Network handlers automatically allocate their tasks with a Starcounter scheduler. Additionally, every session is associated with a specific scheduler. When you run code within a session, Starcounter executes this code on a thread assigned by the session s associated scheduler. The number of tasks that can be executed by Starcounter at the same time is limited, so to optimize performance, it s good to not schedule tasks with the Starcounter scheduler that don t use Starcounter database nor network features. Good opportunities for such optimization are CPU intensive computations and waiting for asynchronous operations to finish. By default, Starcounter creates as many schedulers as there are logical CPU cores. 15 www.starcounter.com

NETWORK LAYER

Starcounter uses its own web server to handle networking. It supports the network protocols UDP, TCP, HTTP, and WebSocket. The web server sends all requests and responses through the Starcounter network gateway. The developer defines where requests are sent by defining network handlers. The addresses for these handlers are registered in the network gateway that use these to send requests and responses to the right places. The API s for the network protocols are low level which gives the developer broad control over networking. Starcounter apps primarily use WebSocket together with the JavaScript networking library Palindrom for client-server communication. Figure 13: Palindrom protocol Palindrom Palindrom is a JavaScript networking library built on JSON Patch (RFC 6902) and WebSocket (RFC 6455). It s used to synchronize JSON trees on the client and the server with as low latency as possible. Two main parts contribute to the reduced latency. First, data sent over WebSocket don t require headers like HTTP requests and responses; this reduces the amount of data sent over the network. Second, with JSON Patch, Palindrom doesn t send the whole view-model each time there s a change; instead, it only sends the changes in a format that looks like this: Palindrom is built to support thin-client apps. This means that the apps have no logic on the client. Button clicks, typing in input fields and similar user interactions are instead sent directly to the server in JSON patches. The code-behind of the Typed JSON handles the input and sends back an immediate response. For the user, it gives the same experience as apps where the client calculates the response. By having thin-client apps, the amount of code can be reduced since there are no HTTP requests and responses to validate, parse, and consume. It also improves security by treating the server as the source of truth and reducing the amount of client-side JavaScript code that can be tampered with. Figure 12: JSON Patch example 17 www.starcounter.com

FRONT-END

As described in the last section, Starcounter uses a thin-client architecture as its front-end solution. By doing this, the views are defined as HTML fragments with little to none JavaScript. Each HTML fragment is inserted in the main HTML document in a place that is controlled by the view-model. The insertion is performed by the Starcounter app shell. This app shell consists of: Palindrom, a CSS framework, and the Starcounter custom element starcounter-include. To effectively use Palindrom, the views are defined with a JavaScript library that implements two-way data bindings. Starcounter recommends Polymer for this purpose, but other libraries, such as React, can be used as well. Two-way data bindings between the view library and the Palindrom data object gives the app developer an abstraction of binding the view directly to the server s view-model. that expose client-side logic. Many Starcounter apps use especially two custom elements: declarative-shadow-dom and starcounterinclude. declarative-shadow-dom is a custom element that lets the app developer define Shadow DOM using an HTML template. Separating DOM from Shadow DOM separates the content from the presentation, which is essential for the View Composition technology that s described in the next section. starcounter-include is a custom element that creates an insertion point for other views. By using starcounter-include, it s possible to create hierarchical user interface structures where views can be nested within one another to create sophisticated user interfaces. Because of View-model attaching, starcounterinclude also inserts views from other apps that represent the same concept. Starcounter Web Components Starcounter apps rely heavily on the suite of web specifications called Web Components that consist of Shadow DOM, Custom Elements and HTML Imports. Shadow DOM provides encapsulation of styling and functionality. Custom Elements are simple to use HTML tags 19 www.starcounter.com

Figure 14: Difference between views with and without custom View Composition View composition lets a designer change the composition of a view and attached views without touching the source of these apps. The purpose of this is to modify the views coming from multiple apps to look and feel like one. Without view composition, the attached views are stacked on top of one another. Shadow DOM enables view composition by separating the presentation from the content. The app developer declares the default composition in the declarative-shadow-dom part of the app view. The customization of the composition is done in the web browser with a tool called BlendingEditor. These changes are then stored in the database. Whenever an app is opened, the custom compositions are retrieved from the database and applied to the view. 20 www.starcounter.com

CONCLUSION

Starcounter is meant to be used to build web apps that interoperate out-of-the-box with little to no configuration or modification. Every component of Starcounter is essential to make this work - from the VMDBMS that lets apps share data to view composition that lets the developer tune apps to look and feel like one. Starcounter is also optimized for developer productivity. Typed JSON, the weaver, and Palindrom all reduce the need for what we call glue code - the code used to integrate different components without contributing to the features of the app. This lets the developer focus on the business logic and thus create value. The developer does not need to configure a database, setup an objectrelational mapper, define large REST interfaces, or deserialize and serialize JSON. Overall, Starcounter vastly simplifies the development and integration of web apps by using the latest database, network, and web technologies. 22 www.starcounter.com