shortcuts:
TOC
NanoTwitter
search:
Starting to think about scaling
(Tue Feb 8, lect 7)
|
previous
|
next
|
slides
|
Sinatra, Service Oriented Architectures and scaling
Logistics
Reminder of how participation homework works
Thoughts about “Begin”
Why were people asking about Gemfiles? What is a Gemfile?
Walk through of a basic scenario
Baseball scoring application - First cut
Millions of fans are constantly refreshing page to see current score in real time as the game progresses
A local official enters stats as the game progresses
Default implementation with a single “monolithic” app
How will things break down?
Assuming:
variable t = total number of teams in this league (guess 100)
variable s = number of games happening simultaneously (guess: 4)
Given a scoreboard app written in Sinatra
What is a good assumption for the number of times per second the page will refresh?
Review of everything so far
What a web server is and how Sinatra helps you create one
Meaning of the URL
ActiveRecord as the bridge between Ruby and the relational database
The relationship between the client and the server
How Unit testing is done with Minitest/Spec et al.
The idea of Test Driven Development
HTTP and it’s different Verbs like GET, PUT, POST etc.
Non Scalable Architecture (good starting point)
A Web Server (aka App Server) runs your code.
That server is connected by network to a database server.
There are background processes and they run on the same server
Scaling it follows a path of least resistance
Scalable Architecture (where you will end up)
As load becomes greater, capacity is added where it is needed
A “load balancer” sends traffic to different servers
A “cache service” like Redis reduces the number of requests to the database
And background processes are also replicated over multiple servers
This kind of configuration is typical of many sites
But what happens when the database cannot carry the load by itself?
Managing the monolithic code base itself also becomes a problem
Test suites take longer to run.
Getting from here to there
It is natural to begin with a monolithic MVC design. This is true if you are implementing in Ruby/Sinatra, Ruby on Rails, Node or any other language.
A Service Oriented Architecture
Some or all the models could be broken off into services, one model per service, or more likely, several models in one service.
This is just a start. We will build on this scheme and use this in NanoTwitter
Thank you. Questions?
(random Image from picsum.photos)
Intro
Cosi105 - Scalability 2022 Syllabus
List of lectures
nanoTwitter
Homeworks
Lectures
Web Apps + Sinatra
Welcome
What is Scalability?
Cosi166 Quick Bullets
Intro to Sinatra
Sinatra and Twitter
NanoTwitter introduced
nano Twitter
Starting to think about scaling
Scaling at Hubspot
Service Oriented Architecture
Deploying to the Cloud
Scalable Service design
Scalability, continued
Testing in the world of SOA
Scaling Patterns
Testing Scalability
Tuning for Scale
Logging
Caching
Database Tuning 1
Database Tuning 2
Concurrency 1
Concurrency 2
Queueing
SOA + µservices
Software Engineering
Scalability Runoff 1
Last class!
Background
Technical Presentations
Misc Links and Resources