building a saas product - software architecture in the cloud era

42
Building a SaaS Software architecture in the cloud era Spyros Magiatis - February 2013 AUEB

Post on 18-Oct-2014

1.824 views

Category:

Technology


1 download

DESCRIPTION

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

TRANSCRIPT

Page 1: Building a SaaS product - software architecture in the cloud era

Building a SaaS Software architecture in the cloud era

Spyros Magiatis - February 2013 AUEB

Page 2: Building a SaaS product - software architecture in the cloud era

Internet services

don’t look like this any

more

Page 3: Building a SaaS product - software architecture in the cloud era

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

Page 4: Building a SaaS product - software architecture in the cloud era

Fortunately you don’t need to reinvent the wheel

Page 5: Building a SaaS product - software architecture in the cloud era

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

Reliability Scalability

Performance Security

Maintenance

Page 6: Building a SaaS product - software architecture in the cloud era

Cloud Types

Page 7: Building a SaaS product - software architecture in the cloud era

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

Page 8: Building a SaaS product - software architecture in the cloud era

PAAS

• A computing platform

• Operating system

• Programming language execution environment

• Database

• Web server

Page 9: Building a SaaS product - software architecture in the cloud era

SAAS• Provides access to

application software

• Cloud providers install and operate application software in the cloud

• Cloud users access the software from cloud clients

Page 10: Building a SaaS product - software architecture in the cloud era

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

Page 11: Building a SaaS product - software architecture in the cloud era

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

Page 12: Building a SaaS product - software architecture in the cloud era

Everything comes at a price

• 30’’ HTTP request timeout

• Limited memory size (1GB)

• Very limited access to file system

Heroku constrains

Page 13: Building a SaaS product - software architecture in the cloud era

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)

Page 14: Building a SaaS product - software architecture in the cloud era

Workable

• Rails App

• Java App

• PostgreSQL

• HBase DB

• Heroku Platform

Page 15: Building a SaaS product - software architecture in the cloud era

And how do you put all these things together?

Page 16: Building a SaaS product - software architecture in the cloud era

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!

Page 17: Building a SaaS product - software architecture in the cloud era

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

Page 18: Building a SaaS product - software architecture in the cloud era

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

Page 19: Building a SaaS product - software architecture in the cloud era

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.

Page 20: Building a SaaS product - software architecture in the cloud era

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:

Page 21: Building a SaaS product - software architecture in the cloud era

Public APIs considerations

• Hide complexity (Coarse-grained)

• Backwards compatibility

• Security

• Asynchronous processing (Webhooks)

Page 22: Building a SaaS product - software architecture in the cloud era

Versioning

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

• Accept header

Page 23: Building a SaaS product - software architecture in the cloud era

Security

• Private keys

• Signup -> Authentication tokens

• HTTPS

Page 24: Building a SaaS product - software architecture in the cloud era

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

Page 25: Building a SaaS product - software architecture in the cloud era

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

Page 26: Building a SaaS product - software architecture in the cloud era

modern UI

Page 27: Building a SaaS product - software architecture in the cloud era

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

Page 28: Building a SaaS product - software architecture in the cloud era

The future is written in Javascript

Page 29: Building a SaaS product - software architecture in the cloud era

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

Page 30: Building a SaaS product - software architecture in the cloud era

REST extravaganza

Page 31: Building a SaaS product - software architecture in the cloud era

Heroku!Rails

WebSolr!Lucene/Solr

REST

REST

Templates

MVCweb sockets

ajax

comet / sse DOM

+

=

Page 32: Building a SaaS product - software architecture in the cloud era

MVC on the client connect to your existing API

Page 33: Building a SaaS product - software architecture in the cloud era

a solr facet with Backbone.js

Page 34: Building a SaaS product - software architecture in the cloud era

Model!!

raw data wrapper storage synchronizer

event channel

View!!

model <-> DOM binder event channel

Template!!

markup + limited logic

Page 35: Building a SaaS product - software architecture in the cloud era
Page 36: Building a SaaS product - software architecture in the cloud era
Page 37: Building a SaaS product - software architecture in the cloud era

A real life scenario

A recruiter sends an email with the resume of a

candidate to a Workable email address

Page 38: Building a SaaS product - software architecture in the cloud era

From email client to Workable

Email Client MailgunEmail ServerSMTP

WorkableNew mail

Create an asynch job

OK

REST

Page 39: Building a SaaS product - software architecture in the cloud era

From Workable to Resume Parser

Workable

Asynch job

AWS S3

upload file

Resume Parser

(Workable)

process file + callback

REST

RESTOK

Redis CacheAsynch job

Page 40: Building a SaaS product - software architecture in the cloud era

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

Page 41: Building a SaaS product - software architecture in the cloud era

• Candidate created in DB

• Resume file uploaded

• Resume file parsed

• Social profiles and avatar retrieved

• Candidate indexed

Page 42: Building a SaaS product - software architecture in the cloud era

Thank you

Spyros Magiatis - February 2013 AUEB