dealing with enterprise level data
webdev@rgu
posh term for ‘lots of’
Today we are looking at:•Tier architecture and cloud computing •Moving from 3-tier to n-tier •Scaling services up for use in Enterprise web
•Caches •Proxies •Load Balancing •Queueing
tier architecture and cloud computing
Presentation Logic
Business LogicData Access
LogicDatabase
1 tier architecture
• All 3 layers are kept on the same machine • Presentation, logic, and data are highly connected
• Bad for scalability (single processor being used • Bad for portability • Bad for maintenance (change one thing…change them all)
Presentation Logic
Business LogicData Access
LogicDatabase
2 tier architectureClient Server
• Database runs on server • Easy if you want to switch to a new database
• Presentation and logic still tightly connected • Bad for server load • Bad if you want to make changes
Presentation Logic
Business LogicData Access
LogicDatabase
3 tier architectureClient Server
• Every layer can be on a different machine • Presentation, logic, and data are all disconnected
DB Server
Presentation Logic
Business LogicData Access
LogicDatabase
3 tier architectureClient Server
• Provides the user interface • Handles interaction with the user • Should not contain any business logic
DB Server
Presentation Logic
Business LogicData Access
LogicDatabase
3 tier architectureClient Server
• Contains rules for processing information • Should not contain any presentation information • Can accommodate many users
DB Server
Presentation Logic
Business LogicData Access
LogicDatabase
3 tier architectureClient Server
• Data storage layer • Manages access to information
DB Server
Presentation Logic
Business LogicData Access
LogicDatabase
3 tier architectureClient Server DB Server
HTML CSS JAVASCRIPT
PHP ASP.NET JAVA javascript(ish)
SQL MONGODB
Easier to maintain
Components are reusable
Faster division of work Web Designer does presentation Software Engineer does logic DB Man does DB things…
moving from 3-tier to n-tier
Availability
Performance
Reliability
Scalability
Managability
Cost
Availability
Performance
Reliability
Scalability
Managability
Cost
Services must be available all the time, no matter what
Availability
Performance
Reliability
Scalability
Managability
Cost
Services must be super fast, no lag time for users
Availability
Performance
Reliability
Scalability
Managability
Cost
Services must be reliable. The data that is returned must be the same every time it is called on
Availability
Performance
Reliability
Scalability
Managability
Cost
Services must be easily upgradable to make space for additional content
Availability
Performance
Reliability
Scalability
Managability
Cost
Services must be easy to manage, and should not break anytime someone touches it
Availability
Performance
Reliability
Scalability
Managability
Cost
Services should be cost efficient, in terms of the money to create it and also the time that it takes to create
As good as this is…it wont work for a big web system
Server Storage
Upload ImageFiles written
to storage
Request Image
Client Computer
Image Located
Image Sent
Server Storage
Upload ImageFiles written
to storage
Request Image
Client Computer
Image Located
Image Sent
make functions to separate services in order to aid in scalability
Image Write
Service
Storage
Upload ImageFiles written
to storage
Request Image
Client Computer
Image Located
Image Sent
Image retrieval
service
Image Write
Service
Storage
Upload ImageFiles written
to storage
Request Image
Client Computer
Image Located
Image Sent
Image retrieval
service
build in redundancy to safeguard data
Image Write
Service
Storage
Upload ImageFiles written
to storage
Request Image
Client Computer
Image Located
Image Sent
Image retrieval
service
Backup Storage
Located in another
geographical location
Image Write
Service
Storage
Upload ImageFiles written
to storage
Request Image
Client Computer
Image Located
Image Sent
Image retrieval
service
Backup Storage
Located in another
geographical location
Think about options to deal with extra large data sets
Image Write
Service
Storage
Upload ImageFiles written
to storage
Request Image
Client Computer
Image Located
Image Sent
Image retrieval
service
Backup Storage
Located in another
geographical location
horizontal and vertical scaling
Horizontal
VerticalAdds more storage / processing power etc. to the same server
Adds more nodes/shards (this is the preferred option for big web services)
Image Write Service
StorageUpload Image Files written
to storage
Request Image
Client Computer
Image Located
Image Sent
Image retrieval
service
Backup Storage
Located in another
geographical location
Image Write Service
StorageBackup Storage
Image retrieval
service
Image Write Service
StorageUpload Image Files written
to storage
Request Image
Client Computer
Image Located
Image Sent
Image retrieval
service
Backup Storage
Located in another
geographical location
Image Write Service
StorageBackup Storage
Image retrieval
service
Services Separate key web services into different logic nodes
Redundancy Make sure that there is backup of all data
Partitions Split everything into different partitions/shards to deal with increasing data usage
Presentation Logic
Business Logic Database
we can go from this…
Presentation Logic
Business Logic
Business Logic
Database
Database
Database
Database
Database
Database
Database
Database
…to this
scaling services up for use in an enterprise level web
program
4 methods that we are going to look at:
Caching Proxies Load Balancing Queuing
scaling services up for use in an enterprise level web
program
Caches
Application Server
Database server
I would like an image of a dog
Application Server
Database server
I would like an image of a dog
too many images to physically sort through
Application Server Database
server
I would like an image of a dog
• Use a cache to store things that are sorted for most recently
• There’s a good chance that if something is searched for once, it is going to be searched for again
cache
Cache is checked before going to the DB server
Application Server Database
server
I would like an image of a dog
• This tiny change makes a big difference to application speed!
• Cache reads are lightning fast • Database server reads are snails pace in comparison
cache
Cache is checked before going to the DB server
Database server
Application Server
cache
Application Server
cache
Application Server
cache
Application Server
cache
I would like an image of a dog
Doesn’t always work as expected. Doing things this way can create a cache miss
Distributed cache system
Database server
Application Server
cache
I would like an image of a
dog
Each request that is made passes through a cache, if it has the data it returns it, if not it goes to the database
Global cache system I
Application Server
Application Server
Application Server
This is the most common type of cache system
Database server
Application Server
cache
I would like an image of a
dog
Application server checks the cache, if it doesn't find what it is after the application server then goes to the database
Global cache system II
Application Server
Application Server
Application Server
Better for large files that may otherwise clog the cache. Also better for static cache files
Want to give it a go?
http://memcached.org/
http://www.phpfastcache.com/(documentation is online)
Caches
scaling services up for use in an enterprise level web
program
proxies
Database server
I would like an image of a
catApplication
Server
Proxy
Database server
I would like an image of a
cat
I would like an image of a
cat
I would like an image of a
cat
I would like an image of a
cat
Application Server
Application Server
Application Server
Application Server
Proxy
Proxies are good when lots of people
are searching for the same thing
Collapses requests into a single
request, reduces database reads
Bring me the cats!
Database server
I would like an image of a
black cat
I would like an image of a
ginger cat
I would like an image of a
tabby cat
I would like an image of a
fluffy cat
Application Server
Application Server
Application Server
Application Server
Proxy
Also good if people are searching for close to the same
thing
Bring me the cats!
Database server
I would like an image of a
black cat
I would like an image of a
ginger cat
I would like an image of a
tabby cat
I would like an image of a
fluffy cat
Application Server
Application Server
Application Server
Application Server
Proxycache
We can use techniques at the same time to make it even faster.
A lot of proxies actually come with a cache built into them
Want to give it a go?
http://www.squid-cache.org/
https://www.varnish-cache.org/(documentation is online)
proxy/cache
scaling services up for use in an enterprise level web
program
load balancing
Database server
I would like an image of a
black cat
I would like an image of a
ginger cat
I would like an image of a
tabby cat
I would like an image of a
fluffy cat
Application Server
Application Server
Application Server
Application Server
Magic Box
!?!?!?!?
I would like an image of a
black cat
upload a picture of a
ginger cat
I want to change my password
I just really like cats
Application Server
Application Server
Application Server
Application Server
Load Balancer
I would like an image of a
black cat
upload a picture of a
ginger cat
I want to change my password
I just really like cats
Application Server
Application Server
Application Server
Application Server
Load Balancer
Load Balancer B
I would like an image of a
black cat
upload a picture of a
ginger cat
I want to change my password
I just really like cats
Application Server
Application Server
Application Server
Application Server
Load Balancer
Load balancing methods
round robin
Random nodeAs it sounds…just picks a random node
Node with most free processing power Node with access to [x]
Criteria based
Location based
node[x], node[x+1], node[x+2]
Node in Aberdeen Node in Dundee
Problems with load balancing
Managing user session dataYou don’t want to be put to a different server node every time you change a page
Even changing a node every time you visit a site would be a pain! (shopping basket might be deleted)
Want to give it a go?
http://www.haproxy.org/(documentation is online)
load balancing
scaling services up for use in an enterprise level web
program
queues
Database server
Application Server
Application Server
Application Server
Application Server
Sends write
Waits for response
Sends write
Sends write
Sends write
Waits for response
Waits for response
Waits for response
this is torture
Queues are good for writing data
caches, proxies and load balancing are all good for reading data
Database server
Application Server
Application Server
Application Server
Application Server
Sends write
Sends write
Sends write
Sends write
queue
writing to the queue gets instant acknowledgment
Sends writes when
database is available
Want to give it a go?
http://zookeeper.apache.org/
http://www.rabbitmq.com/(documentation is online)
queues
Recap•Tier architecture and cloud computing •Moving from 3-tier to n-tier •Scaling services up for use in Enterprise web
•Caches •Proxies •Load Balancing •Queueing
Top Related