building a saas product - software architecture in the cloud era

Post on 18-Oct-2014

1.823 Views

Category:

Technology

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

Learning from Workable's experience building a cloud-based software architecture for Software-as-a-Service

TRANSCRIPT

Building a SaaS Software architecture in the cloud era

Spyros Magiatis - February 2013 AUEB

Internet services

don’t look like this any

more

Customers WebsitesSocial Search!

FullContact

Cache!Redis

Cache!Redis

File Storage!S3

You start with a simple idea and then …

CDN!Cloudfront

Email!Mailgun

Monitoring!NewRelic

Platform!Heroku

Your Rails App

Logging!Papertrail

Full Text!Websolr

Big Data!HBase

User!Analytics!

Kissmetrics

Error Monitoring!

Honeybadger

Customer Support!IntercomYour Java App

Billing!BraintreeDB!

Heroku Postgres

Social Media!

Syndicated Sites

Fortunately you don’t need to reinvent the wheel

Cloud ComputingAgility APIs Cost Device & location independence Virtualisation Multi-tenancy

Reliability Scalability

Performance Security

Maintenance

Cloud Types

IAAS• Basic cloud-service model

• Physical or (more often) virtual servers

• Hypervisor, such as Hyper-V or Xen or KVM or VMware ESX/ESXi, runs the virtual machines as guests

• Hypervisors support large numbers of virtual machines

• Scale services up and down according to customers' varying requirements

• Additional resources such as a virtual-machine disk image library, raw (block) and file-based storage, firewalls, load balancers, IP addresses

PAAS

• A computing platform

• Operating system

• Programming language execution environment

• Database

• Web server

SAAS• Provides access to

application software

• Cloud providers install and operate application software in the cloud

• Cloud users access the software from cloud clients

A sensible decision

• Pick the right PaaS for your application

• Complement the functionality of your service with other SaaS

• Use IaaS when needed

• Adjust as you grow

Heroku• Popular PAAS vendor

• Ruby, Node.js, Python, and Java

• Dynos

• abstract computing environments

• virtualized Unix-style containers run processes in isolated environments

• Integration with Git

• Configuration information through environment variables

• Heroku Postgres

• Hundreds of add-ons

Everything comes at a price

• 30’’ HTTP request timeout

• Limited memory size (1GB)

• Very limited access to file system

Heroku constrains

Workarounds

• Run long lasting transaction as background jobs

• Replace file system with external storage services (AWS S3)

• Use external logging services (Papertrail)

• Use external error logging services (Honeybadger)

Workable

• Rails App

• Java App

• PostgreSQL

• HBase DB

• Heroku Platform

And how do you put all these things together?

Jeff Bezos 2002: !All teams will henceforth expose their data and functionality through service interfaces.!!

There will be no other form of inter-process communication allowed: no direct linking, no direct reads of another team’s data store, no shared-memory model, no back-doors whatsoever. The only communication allowed is via service interface calls over the network.!!

Anyone who doesn’t do this will be fired. Thank you; have a nice day!

REST• Simple stateless architecture that generally runs

over HTTP

• Assigning resources (nouns) their own unique universal resource indicators (URIs)

• Vocabulary of operations called request methods, most notably: GET, POST, PUT, DELETE

• Format of the information (representation) returned, which is typically an HTML, XML, or JSON document of some kind

Understanding RESTREST request path Action name Description

GET /jobs index List of all jobs

POST /jobs create Create a single new job from the received data

GET /jobs/1 show Return a single existing job

PUT /jobs/1 update Update a single existing job from the received data

DELETE /jobs/1 destroy Destroy a single existing job

REST Mindset• Resource-oriented approach encourages you to

think about your business logic from the data standpoint

• Exposing resources to endpoints that perform CRUD actions.

• This approach takes some getting used to, but once you've adopted that mindset, it helps in keeping your interfaces consistent and predictable by other developers.

JSON

{ "title":"Web Developer", "code":"ATH/6", "shortcode":"A126A01AB1", "country":"Greece", "state":"Attiki", "city":"Athens", "department":"Software Development", "created_at":"2012-12-11"

}

Human-readable text to transmit data objects consisting of attribute–value pairs

JOB:

Public APIs considerations

• Hide complexity (Coarse-grained)

• Backwards compatibility

• Security

• Asynchronous processing (Webhooks)

Versioning

• Embedded in URIs: /api/v1/jobs/1

• Accept header

Security

• Private keys

• Signup -> Authentication tokens

• HTTPS

Asynchronous processing with web hooks

Service Consumer Server

Request + callback URL

OK long lasting transaction

Client

Webhook Result

• Temp storage for pending transactions

• Cleanup temp storage

• Retry policy

DB!Heroku

Postgres

File Storage!AWS S3

Insights!Google

Analytics

Platform!Heroku Rails/Node

Logging!Papertrail

Customer Support!Intercom

Full Text!WebSolr

CDN!AWS

Cloudfront

Big Data!cloudera

Cache!Redis

modern UI

is no longer dummy• many browsers

• on many devices

• with new abilities

• on networks of variant speed

• used by people with short attention spans and event shorter patience

• who want great performance

• and expect ease of use using a smooth & fault tolerant UI

• =>

• +1 thick business logic layer

The future is written in Javascript

a new ecosystem• MVC in the browser

• Templating engines

• Web Components - <calendar/>

• AMD - RequireJS

• Pub/Sub & Reactive programming

• HTML5 - threads, offline storage

• CSS3 - GPU powered animations

• Dependency Management Tools

• Build Tools

• Testing frameworks

React

REST extravaganza

Heroku!Rails

WebSolr!Lucene/Solr

REST

REST

Templates

MVCweb sockets

ajax

comet / sse DOM

+

=

MVC on the client connect to your existing API

a solr facet with Backbone.js

Model!!

raw data wrapper storage synchronizer

event channel

View!!

model <-> DOM binder event channel

Template!!

markup + limited logic

A real life scenario

A recruiter sends an email with the resume of a

candidate to a Workable email address

From email client to Workable

Email Client MailgunEmail ServerSMTP

WorkableNew mail

Create an asynch job

OK

REST

From Workable to Resume Parser

Workable

Asynch job

AWS S3

upload file

Resume Parser

(Workable)

process file + callback

REST

RESTOK

Redis CacheAsynch job

Full Contact

From Workable to Resume Parser

Workable

Asynch jobdownload resume file

AWS S3

Resume Parser

Workable

Social search + callback

REST

REST

OK

Redis CacheQuick parsing

REST

Temp Results

Search the internet

Social Profiles

Final parsing

Update Candidate

REST

WebSolrREST

index

some social network

download avatar

Continue Asynchronously

upload avatar

• Candidate created in DB

• Resume file uploaded

• Resume file parsed

• Social profiles and avatar retrieved

• Candidate indexed

Thank you

Spyros Magiatis - February 2013 AUEB

top related