Dealing with Enterprise Level Data

63
dealing with enterprise level data webdev@rgu posh term for ‘lots of’

Transcript of Dealing with Enterprise Level Data

Page 1: Dealing with Enterprise Level Data

dealing with enterprise level data

webdev@rgu

posh term for ‘lots of’

Page 2: Dealing with Enterprise Level Data

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

Page 3: Dealing with Enterprise Level Data

tier architecture and cloud computing

Page 4: Dealing with Enterprise Level Data

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)

Page 5: Dealing with Enterprise Level Data

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

Page 6: Dealing with Enterprise Level Data

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

Page 7: Dealing with Enterprise Level Data

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

Page 8: Dealing with Enterprise Level Data

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

Page 9: Dealing with Enterprise Level Data

Presentation Logic

Business LogicData Access

LogicDatabase

3 tier architectureClient Server

• Data storage layer • Manages access to information

DB Server

Page 10: Dealing with Enterprise Level Data

Presentation Logic

Business LogicData Access

LogicDatabase

3 tier architectureClient Server DB Server

HTML CSS JAVASCRIPT

PHP ASP.NET JAVA javascript(ish)

SQL MONGODB

Page 11: Dealing with Enterprise Level Data

Easier to maintain

Components are reusable

Faster division of work Web Designer does presentation Software Engineer does logic DB Man does DB things…

Page 12: Dealing with Enterprise Level Data

moving from 3-tier to n-tier

Page 13: Dealing with Enterprise Level Data

Availability

Performance

Reliability

Scalability

Managability

Cost

Page 14: Dealing with Enterprise Level Data

Availability

Performance

Reliability

Scalability

Managability

Cost

Services must be available all the time, no matter what

Page 15: Dealing with Enterprise Level Data

Availability

Performance

Reliability

Scalability

Managability

Cost

Services must be super fast, no lag time for users

Page 16: Dealing with Enterprise Level Data

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

Page 17: Dealing with Enterprise Level Data

Availability

Performance

Reliability

Scalability

Managability

Cost

Services must be easily upgradable to make space for additional content

Page 18: Dealing with Enterprise Level Data

Availability

Performance

Reliability

Scalability

Managability

Cost

Services must be easy to manage, and should not break anytime someone touches it

Page 19: Dealing with Enterprise Level Data

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

Page 20: Dealing with Enterprise Level Data

As good as this is…it wont work for a big web system

Page 21: Dealing with Enterprise Level Data

Server Storage

Upload ImageFiles written

to storage

Request Image

Client Computer

Image Located

Image Sent

Page 22: Dealing with Enterprise Level Data

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

Page 23: Dealing with Enterprise Level Data

Image Write

Service

Storage

Upload ImageFiles written

to storage

Request Image

Client Computer

Image Located

Image Sent

Image retrieval

service

Page 24: Dealing with Enterprise Level Data

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

Page 25: Dealing with Enterprise Level 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

Page 26: Dealing with Enterprise Level 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

Think about options to deal with extra large data sets

Page 27: Dealing with Enterprise Level 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

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)

Page 28: Dealing with Enterprise Level Data

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

Page 29: Dealing with Enterprise Level Data

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

Page 30: Dealing with Enterprise Level Data

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

Page 31: Dealing with Enterprise Level Data

Presentation Logic

Business Logic Database

we can go from this…

Page 32: Dealing with Enterprise Level Data

Presentation Logic

Business Logic

Business Logic

Database

Database

Database

Database

Database

Database

Database

Database

…to this

Page 33: Dealing with Enterprise Level Data

scaling services up for use in an enterprise level web

program

Page 34: Dealing with Enterprise Level Data

4 methods that we are going to look at:

Caching Proxies Load Balancing Queuing

Page 35: Dealing with Enterprise Level Data

scaling services up for use in an enterprise level web

program

Caches

Page 36: Dealing with Enterprise Level Data

Application Server

Database server

I would like an image of a dog

Page 37: Dealing with Enterprise Level Data

Application Server

Database server

I would like an image of a dog

too many images to physically sort through

Page 38: Dealing with Enterprise Level Data

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

Page 39: Dealing with Enterprise Level Data

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

Page 40: Dealing with Enterprise Level Data

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

Page 41: Dealing with Enterprise Level Data

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

Page 42: Dealing with Enterprise Level Data

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

Page 43: Dealing with Enterprise Level Data

Want to give it a go?

http://memcached.org/

http://www.phpfastcache.com/(documentation is online)

Caches

Page 44: Dealing with Enterprise Level Data

scaling services up for use in an enterprise level web

program

proxies

Page 45: Dealing with Enterprise Level Data

Database server

I would like an image of a

catApplication

Server

Proxy

Page 46: Dealing with Enterprise Level Data

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!

Page 47: Dealing with Enterprise Level Data

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!

Page 48: Dealing with Enterprise Level Data

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

Page 49: Dealing with Enterprise Level Data

Want to give it a go?

http://www.squid-cache.org/

https://www.varnish-cache.org/(documentation is online)

proxy/cache

Page 50: Dealing with Enterprise Level Data

scaling services up for use in an enterprise level web

program

load balancing

Page 51: Dealing with Enterprise Level Data

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

!?!?!?!?

Page 52: Dealing with Enterprise Level Data

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

Page 53: Dealing with Enterprise Level Data

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

Page 54: Dealing with Enterprise Level Data

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

Page 55: Dealing with Enterprise Level Data

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)

Page 56: Dealing with Enterprise Level Data

Want to give it a go?

http://www.haproxy.org/(documentation is online)

load balancing

Page 57: Dealing with Enterprise Level Data

scaling services up for use in an enterprise level web

program

queues

Page 58: Dealing with Enterprise Level Data

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

Page 59: Dealing with Enterprise Level Data

this is torture

Page 60: Dealing with Enterprise Level Data

Queues are good for writing data

caches, proxies and load balancing are all good for reading data

Page 61: Dealing with Enterprise Level 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

Page 62: Dealing with Enterprise Level Data

Want to give it a go?

http://zookeeper.apache.org/

http://www.rabbitmq.com/(documentation is online)

queues

Page 63: Dealing with Enterprise Level Data

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