Upgrade to Pro — share decks privately, control downloads, hide ads and more …

[2017.05 Meetup #13] [TALK #1] André Cruz - Bui...

[2017.05 Meetup #13] [TALK #1] André Cruz - Building Scalable Systems

When building scalable systems certain decisions have to be made beforehand. In this talk I'll discuss some of them that I had to make while working at SAPO, and also relate some ways to better deal with and prevent scalability failures.

André Cruz is a systems engineer with a passion for functional languages and information security.

DevOps Lisbon

May 15, 2017
Tweet

More Decks by DevOps Lisbon

Other Decks in Technology

Transcript

  1. Agenda • Intro and motivation • Scalability decisions • Storing

    state • Concurrency model • Scalability failures • Q&A
  2. –Wikipedia “Scalability is the capability of a system, network, or

    process to handle a growing amount of work, or its potential to be enlarged in order to accommodate that growth.”
  3. Is scalability important? • Google: increasing page load time from

    0.4 seconds to 0.9 seconds decreased traffic and ad revenues by 20%. • Amazon: every 0.1 second increase in load time decreases sales by 1%. "Website Optimization", Andrew B. King
  4. Performance vs Scalability • Performance problem: the system is slow

    for a single user. • Scalability problem: the system is fast for a single user, but slow with lots of concurrent users.
  5. Handling scalability • Doing nothing: degraded app • Throttling: deny

    the service to new users to better serve existing or important users • Optimize resource usage: better programming model • Adding resources: scale up or out • Delegating scalability: serverless • Caching: mitigation
  6. –Leon Bambrick “There are only 2 hard problems in computer

    science: cache invalidation, naming things, and off-by-1 errors.”
  7. Example applications • SAPO Blogs - 2005 - http://blogs.sapo.pt/ •

    SAPO ID/SSO - 2008 - https://id.sapo.pt/ • MEO Cloud - 2012 - https://meocloud.pt/
  8. RDBMS Scale out - queries • Scaling out a RDBMS

    is hard • reads - difficult • writes - impossible
  9. RDBMS Scale out - data • Scaling a RDBMS ->

    sharding • Partitioning • Replication • NOSQL
  10. Which one? • Different data may have different needs •

    ACID -> RDBMS • Volume of data does not fit master -> NOSQL • Volume of write queries too big -> NOSQL
  11. How high can you go? Azure Standard_GS5 CPU cores Memory

    : GiB Local SSD: GiB Max data disks Max cached and local disk throughput: IOPS / MBps (cache size in GiB) Max uncached disk throughput: IOPS / MBps 32 448 896 64 160,000 / 1,600 (4,224) 80,000 / 2,000
  12. Example applications • SAPO Blogs - Sharded relational database •

    SAPO ID/SSO - Relational database • MEO Cloud - NoSQL store
  13. Threads 1 Request <-> 1 Thread SAPO ID • Apache

    worker mpm + mod_python/mod_jk
  14. Threads function isUserTooYoung(id) { db = openDatabase() col = getCollection(db,

    'users') user = find(col, {'id': id}) return user.age < cutoffAge }
  15. Callbacks function isUserTooYoung(id, callback) { openDatabase(function(db) { getCollection(db, 'users', function(col)

    { find(col, {'id': id},function(result) { result.filter(function(user) { callback(user.age < cutoffAge) }) }) }) }) }
  16. Coroutines async function isUserTooYoung(id) { const db = await openDatabase()

    const col = await getCollection(db, 'users') const user = await find(col, {'id': id}) return user.age < cutoffAge }