iMobileMagic Teck Talk Scale Up

12

Transcript of iMobileMagic Teck Talk Scale Up

Page 1: iMobileMagic Teck Talk Scale Up
Page 2: iMobileMagic Teck Talk Scale Up

Scale up

Pedro Machado – Soft. [email protected]

Page 3: iMobileMagic Teck Talk Scale Up

How To Scale

• Vertical Scaling (Scale Up)

• Upgrade the server hardware

• Throw in more RAM, faster disk(s), CPU, etc

• Horizontal Scaling (Scale Out)

• Spin up another server instance

Page 4: iMobileMagic Teck Talk Scale Up

Vertical Scaling

• Advantages

• No code changes required

• Easy and fast to do – AWS

• No need to manage multiple machines

• Disadvantages

• Expensive

• Single point of failure

• Vendor lock-in

Page 5: iMobileMagic Teck Talk Scale Up

Horizontal Scaling

• Advantages

• Continuous availability/redundancy

• Continuous upgrades, with no downtime

• Better perfomance

• Disadvantages

• May required code/architectural changes

• Manage multiple machines

• Developing distributed systems can be complex

Page 6: iMobileMagic Teck Talk Scale Up

Before Scaling

• Cache, cache and cache!

• AWS – ElastiCache, Memcached, Redis

• Avoid unnecessary queries

• Tune your server / application

• Use indexes, wisely

• EXPLAIN SELECT * FROM Table WHERE name = ‘John’;

• Find and fix your bottlenecks

Page 7: iMobileMagic Teck Talk Scale Up

Database Scaling

• Sharding :

• Distribute table rows onto different servers

• Example: Customer table -> US customers are on ServerUS, EU customers on

ServerEU

• Partitioning

• Master-slave

• Inserts and Updates go to the master, reads go to the slave

• The single Master server is a limitation to scalability. Can quickly create a

bottleneck.

• Near real time – if master dies data may be lost.

Page 8: iMobileMagic Teck Talk Scale Up

Server Scaling – Microservices

Page 9: iMobileMagic Teck Talk Scale Up

Server Scaling – Microservices

• The pros

• A service should only do one thing and do it well

• A service is fully independent - self contained

• Has it’s own database type and tech stack (language agnostic)

• Fast deploys, tiny EAR = super fast deploy

• Loosely coupled - communicate asynchronously via messages/events,

queues or REST (sync)

• Self monitoring, e.g. Circuit Breaker, Bulkhead

• Greater resiliency – fault isolation

• Independent dev teams

Page 10: iMobileMagic Teck Talk Scale Up

Server Scaling – Microservices

• The cons

• Service discovery

• Distributed services are complex to deal with

• Fan out of requests

• 1 request in a monolithic application can be equal to multiple requests in a

microservices architecture

• Serialization overhead

• Latency

Page 11: iMobileMagic Teck Talk Scale Up

General Tips

• Monitor your server resources

• Set and configure alarms

• Elastic scaling

• Use AWS auto-scaling feature in conjunction with CloudWatch

• When X metric is above the limit-> spin up another instance

• When X metric is back to normal values -> kill an instance to save up costs

• https://www.youtube.com/watch?v=7SfVZqOVcCI

Page 12: iMobileMagic Teck Talk Scale Up