+ All Categories
Home > Software > No More Mr. Nice Guy The MEAN Stack

No More Mr. Nice Guy The MEAN Stack

Date post: 18-Jan-2017
Category:
Upload: will-button
View: 369 times
Download: 7 times
Share this document with a friend
25
No More Mr. Nice Guy The MEAN Stack
Transcript
Page 1: No More Mr. Nice Guy   The MEAN Stack

No More Mr. Nice Guy

The MEAN Stack

Page 2: No More Mr. Nice Guy   The MEAN Stack

What we will coverFault toleranceScalabilityPerformance

MongodbExpress.jsAngularNode.js(a.k.a. the MEAN stack)

Page 3: No More Mr. Nice Guy   The MEAN Stack

What we won't coverDetailed implementation

Page 4: No More Mr. Nice Guy   The MEAN Stack

Why the MEAN stack?MongodbExpress.jsAngularNode.js

CassandraReactAWS API GatewayPython

Page 5: No More Mr. Nice Guy   The MEAN Stack

Goals of a Highly Available EnvironmentFault toleranceScalablePerformance

Programming today is a race between software engineers striving to build bigger and better idiot-proof

programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.-- Rick Cook, The Wizardry Compiled (1989)

Page 6: No More Mr. Nice Guy   The MEAN Stack

Building Our Environment

PM2 { “apps”: [{ “name”: “App1”, “script”: “server.js” “instances”: 0, “max_memory_restart”: “2G” }]}

Node.js

Page 7: No More Mr. Nice Guy   The MEAN Stack

Scaling Node.js

Node.js Node.js Node.js

Elastic Load Balancer

Page 8: No More Mr. Nice Guy   The MEAN Stack

Use The VPC, Luke

Node.js Node.js Node.js

Elastic Load Balancer

Page 9: No More Mr. Nice Guy   The MEAN Stack

Availability Zone CAvailability Zone BAvailability Zone A

Geographical Fault Tolerance

Node.js Node.js Node.js

Elastic Load Balancer

Page 10: No More Mr. Nice Guy   The MEAN Stack

Availability Zone CAvailability Zone BAvailability Zone A

Adding Our MongoDB Servers

MongoDB1 MongoDB2 MongoDB3

Node.js Node.js Node.js

Elastic Load Balancer

Page 11: No More Mr. Nice Guy   The MEAN Stack

Availability Zone CAvailability Zone BAvailability Zone A

MongoDB Fault Tolerance

MongoDB1 MongoDB2 MongoDB3MongoDB1 MongoDB2 MongoDB3

Node.js Node.js Node.js

Elastic Load Balancer

module.exports = { db: 'mongodb://MongoDB1/myApp,MongoDB2/myApp,MongoDB2/myApp', dbOptions: { server: { replset: { rs_name: 'myReplicaSet', readPreference: 'nearest' } }

Page 12: No More Mr. Nice Guy   The MEAN Stack

EuropeUnited StatesChina

Scaling MongoDB

MongoDB1MongoDB1

MongoDB1

MongoDB1MongoDB2

MongoDB2

MongoDB1MongoDB3

MongoDB3MongoDB1 MongoDB2 MongoDB3

Node.js Node.js Node.js

Elastic Load Balancer

Page 13: No More Mr. Nice Guy   The MEAN Stack

EuropeUnited StatesChina

Scaling MongoDB

MongoDB1MongoDB1

MongoDB1

MongoDB1MongoDB2

MongoDB2

MongoDB1MongoDB3

MongoDB3MongoDB1 MongoDB2 MongoDB3

Node.js Node.js Node.js

Elastic Load Balancer

MongoDB || Cassandra || MySql || Postgresql || Couchdb || etc...

Page 14: No More Mr. Nice Guy   The MEAN Stack

Breaking The Bank

Availability Zone CAvailability Zone BAvailability Zone A

MongoDB1 MongoDB2 MongoDB3MongoDB1 MongoDB2 MongoDB3

Node.js Node.js Node.js

Elastic Load Balancer

Page 15: No More Mr. Nice Guy   The MEAN Stack

Breaking The Bank

Availability Zone CAvailability Zone BAvailability Zone A

MongoDB1 MongoDB2 MongoDB3

Node.js Node.js Node.js

Elastic Load Balancer

ELB ($20/month):3 Node.js servers: 3 MongoDB servers:

t2.medium: 2 CPU/ 4GB RAM

$ 20$120$120

$260/month

Page 16: No More Mr. Nice Guy   The MEAN Stack

But How Much Is That… really?

Availability Zone CAvailability Zone BAvailability Zone A

MongoDB3

t2.medium: 2 CPU/ 4GB RAM

MongoDB1 MongoDB2 MongoDB3

Node.js Node.js Node.js

Elastic Load Balancer

500 - 1000 requests per minute

Page 17: No More Mr. Nice Guy   The MEAN Stack

EuropeUnited StatesChina

Scaling Even More...

MongoDB1MongoDB1

MongoDB1

MongoDB1MongoDB2

MongoDB2

MongoDB1MongoDB3

MongoDB3MongoDB1 MongoDB2 MongoDB3

Node.js Node.js Node.js

Elastic Load Balancer

Node.js Node.js

Page 18: No More Mr. Nice Guy   The MEAN Stack

EuropeUnited StatesChina

Scaling Even More...

MongoDB1MongoDB1

MongoDB1MongoDB2

MongoDB1MongoDB3

MongoDB1 MongoDB2 MongoDB3

Node.js

Node.js

Node.js

Elastic Load Balancer

Page 19: No More Mr. Nice Guy   The MEAN Stack

EuropeUnited StatesChina

Scaling Even More...

MongoDB1MongoDB1

MongoDB1

MongoDB1MongoDB2

MongoDB2

MongoDB1MongoDB3

MongoDB3

CDN

MongoDB1 MongoDB2 MongoDB3

Node.js Node.js Node.js

Elastic Load Balancer

Page 20: No More Mr. Nice Guy   The MEAN Stack

EuropeUnited StatesChina

Scaling Even More...

MongoDB1MongoDB1

MongoDB1MongoDB2

MongoDB1MongoDB3

Elasticsearch

Elasticsearch

Elasticsearch

MongoDB1 MongoDB2 MongoDB3

Node.js Node.js Node.js

Elastic Load Balancer

Page 21: No More Mr. Nice Guy   The MEAN Stack

Monitoring

CPU utilization - percentage of time CPU spends doing workCPU load - measure of computational work averaged over timeMemory utilization - percentage of memory allocatedDisk space - amount of disk space allocated vs. availableNetwork throughput - amount of traffic (in bytes)

CPU Wait - indicates time spent by the CPU waiting for resources to come availableCPU Steal - indicates time not available to the CPU due to the underlying host

Page 22: No More Mr. Nice Guy   The MEAN Stack

Monitoring

Page 23: No More Mr. Nice Guy   The MEAN Stack

Monitoring

Page 24: No More Mr. Nice Guy   The MEAN Stack

• Know your goal (MVP or HA)• Monitoring drives direction• Load-test all the things• Learn to forecast expenses

Take-aways

Page 25: No More Mr. Nice Guy   The MEAN Stack

Resources

Links:• http://www.mean.io• https://angularjs.org/• http://expressjs.com/• https://www.mongodb

.org/• http://aws.amazon.co

m/• http://kkovacs.eu/cas

sandra-vs-mongodb-vs-couchdb-vs-redis

Will Button @wfbuttonhttp://willbutton.co

Don’t be jealous that I was at IteratePhx chatting with Will Button all day.


Recommended