134
Do Cheaters Prosper? UNDERSTANDING THE RULES OF APPLICATION DEVELOPMENT Scott Tadman (Chief of Research) / Dom Bortolussi (CEO), TWG @tadmanter @dombort @twg

Do cheaters prosper? Understanding the rules of application development

Embed Size (px)

DESCRIPTION

From an early age, we are told that cheating is bad. There are rules we’re supposed to follow, and breaking these rules – we’re told – is a big no-no. No ice-cream before dinner, no peeking at your classmate’s test, no cutting in line for lunch… or else. But is cheating always a bad thing? Bad cheating breaks the law, puts people at risk or has severe negative consequences. If you’re making a program to run a nuclear reactor: don’t cheat. If something goes wrong then there will be very bad consequences. Good cheating is like a magic trick: it’s a method to achieve a desired effect. Just don’t get caught. Getting caught ruins the magic and gets you in trouble. Do things “wrong”, get dirty, use hacks, and optimize for very specific cases. Do all this in order to deliver the desired effect. Applications capture, retrieve and display resources. These resources have costs, such as the cost of transmission, processing and storage. Different resources have varying probabilities of being required; some may be requested and others not, some may be requested frequently and others rarely. These are all things to consider when deciding what processes can and need to be optimized, which will in turn help you choose from your magic bag of tricks. Here’s a quick barometer for deciding when to cheat: - Requests that are free or cheap to deliver and are rare are not worth optimizing since these are essentially effortless already - Requests that are expensive but rare aren’t a priority, feel free to procrastinate on these - Requests that are free or cheap and happen frequently are the fun ones to optimize - Requests that are frequent and expensive are your big wins… if you can figure out how to optimize them.

Citation preview

Page 1: Do cheaters prosper? Understanding the rules of application development

Do Cheaters Prosper?UNDERSTANDING THE RULES

OF APPLICATION DEVELOPMENT

Scott Tadman (Chief of Research) / Dom Bortolussi (CEO), TWG @tadmanter @dombort @twg

Page 2: Do cheaters prosper? Understanding the rules of application development

“The Rules”

• These are taught to you in school.

• Based on conventions, shaped by tradition.

• Supposed to steer you towards best practices.

• Usually distorted by superstition and paranoia.

Page 3: Do cheaters prosper? Understanding the rules of application development

“The Rules”

• These arbitrary rules put you in a box.

• They limit your thinking.

Page 4: Do cheaters prosper? Understanding the rules of application development

“The Box”

Page 5: Do cheaters prosper? Understanding the rules of application development

“Cheating”

• Defies convention.

• Thinks “outside the box”.

• Breaks “rules”.

• Yields an “unfair” advantage.

Page 6: Do cheaters prosper? Understanding the rules of application development

Cheating?

• Isn’t cheating bad?

Page 7: Do cheaters prosper? Understanding the rules of application development

Bad Cheating

• Breaks laws.

• Puts people at risk.

• Has severe negative consequences.

Page 8: Do cheaters prosper? Understanding the rules of application development

Good Cheating

• Often called “hacks” or “tricks”

• Circumvents ritual or tradition.

• Cutting corners.

Page 9: Do cheaters prosper? Understanding the rules of application development

Good Cheating

Page 10: Do cheaters prosper? Understanding the rules of application development

Good Cheating

Page 11: Do cheaters prosper? Understanding the rules of application development

Bad Cheating

Page 12: Do cheaters prosper? Understanding the rules of application development

Bad Cheating

• We usually call it “illegal”.

• Like get you into jail illegal.

Page 13: Do cheaters prosper? Understanding the rules of application development

So what are the rules?

Page 14: Do cheaters prosper? Understanding the rules of application development

The Application’s Rules

• Don’t crash on me.

• Don’t waste my time.

• Don’t lie to me.

• Don’t forget my things.

• Don’t cost me money/bandwidth.

Page 15: Do cheaters prosper? Understanding the rules of application development

Important Rule

• Don’t kill me.

Page 16: Do cheaters prosper? Understanding the rules of application development

Asimov’s Law

• “A robot may not harm a human being.”

Page 17: Do cheaters prosper? Understanding the rules of application development

Developer’s Law?

• “An application may not harm a human being.”

Page 18: Do cheaters prosper? Understanding the rules of application development

“Fatal Error?”

Page 19: Do cheaters prosper? Understanding the rules of application development

Nuclear Reactor

Page 20: Do cheaters prosper? Understanding the rules of application development

Nuclear Reactor

Page 21: Do cheaters prosper? Understanding the rules of application development

Nuclear Reactor

Page 22: Do cheaters prosper? Understanding the rules of application development

Doh

Nuclear Reactor

Page 23: Do cheaters prosper? Understanding the rules of application development

Consequences?

Page 24: Do cheaters prosper? Understanding the rules of application development

We all die.

Page 25: Do cheaters prosper? Understanding the rules of application development
Page 26: Do cheaters prosper? Understanding the rules of application development

X-Ray Machine

Page 27: Do cheaters prosper? Understanding the rules of application development

X-Ray Machine

Page 28: Do cheaters prosper? Understanding the rules of application development

X-Ray Machine

Page 29: Do cheaters prosper? Understanding the rules of application development

X-Ray Machine

Yikes.

Page 30: Do cheaters prosper? Understanding the rules of application development

Consequences?

Page 31: Do cheaters prosper? Understanding the rules of application development

Someone dies.

Page 32: Do cheaters prosper? Understanding the rules of application development

The ApplicationYou’re Building

Page 33: Do cheaters prosper? Understanding the rules of application development

Most Applications

Page 34: Do cheaters prosper? Understanding the rules of application development

Typical Application

Bah.

Page 35: Do cheaters prosper? Understanding the rules of application development

Consequences?

Page 36: Do cheaters prosper? Understanding the rules of application development

Nobody dies.

Page 37: Do cheaters prosper? Understanding the rules of application development

Don’t worry so much.

Page 38: Do cheaters prosper? Understanding the rules of application development

Most Applications

• Won’t kill people.

• Won’t misplace lots of money.

• Won’t destroy the universe.

• Have a lot of opportunities to “cheat”.

Page 39: Do cheaters prosper? Understanding the rules of application development

“Cheating”

Page 40: Do cheaters prosper? Understanding the rules of application development

It’s like a magic trick.

Page 41: Do cheaters prosper? Understanding the rules of application development

Don’t get caught.

Page 42: Do cheaters prosper? Understanding the rules of application development

It ruins it.

Page 43: Do cheaters prosper? Understanding the rules of application development

Successful Cheating

• Don’t let me catch you crashing on me.

• Don’t let me catch you wasting my time.

• Don’t let me catch you lying to me.

• Don’t let me catch you forgetting my things.

• Don’t let me catch you costing me money/bandwidth.

Page 44: Do cheaters prosper? Understanding the rules of application development

Successful Cheating

• It’s all about not getting caught.

Page 45: Do cheaters prosper? Understanding the rules of application development

A Magic Trick

• Rough definition:

• A method to achieve the desired effect.

Page 46: Do cheaters prosper? Understanding the rules of application development

An Application

• Rough definition:

• A programmed method to achieve desired effects.

Page 47: Do cheaters prosper? Understanding the rules of application development

Performance Cheats

Page 48: Do cheaters prosper? Understanding the rules of application development

Performance Cheats

• Doing the “wrong” thing.

• Getting “dirty”, introducing “hacks”.

• Optimized for very specific cases.

• Are focused on delivering the desired effects.

• It’s always about perception.

Page 49: Do cheaters prosper? Understanding the rules of application development

Applications Deconstructed

• Capture, retrieve and display resources.

• Resources have varying costs including:

• Cost of transmission.

• Cost of processing.

• Cost of storage.

Page 50: Do cheaters prosper? Understanding the rules of application development

Application Fundamentals

• Resources may or may not be requested.

• Resources have varying probabilities of being required.

• Some requests are frequent.

• Some requests are rare.

Page 51: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Optimization Regions

The BoxExpensive

Rare

Free

Frequent

Generalized solutions to generalized problems.

Page 52: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Optimization Regions

Effortless

Expensive

Rare

Free

Frequent

These don’t require optimization.

Page 53: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Optimization Regions

Effortless Procrastinate

Expensive

Rare

Free

Frequent

These aren’t a priority.

Page 54: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

ExpensiveLow

Rare

High

Optimization Regions

Pleasure

Effortless Procrastinate

Free

Frequent

These are the ones we love to fix.

Page 55: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Optimization Regions

PainPleasure

Effortless Procrastinate

Expensive

Rare

Free

Frequent

Big wins...if you can figure out how.

Page 56: Do cheaters prosper? Understanding the rules of application development

Bandwidth

System Power

Low

High

Resources

Marginal

None

Unlimited

Unlimited

Personal Computer

MobileSingle Server

Server Cluster

Page 57: Do cheaters prosper? Understanding the rules of application development

Fundamental Strategies

Page 58: Do cheaters prosper? Understanding the rules of application development

Perception Matters

• Performance is all about perception.

• People are oblivious to your best.

• People will remember your worst.

• Outliers are what people perceive the most.

• Remember: If the application “feels” fast, it is fast.

Page 59: Do cheaters prosper? Understanding the rules of application development

“Cheater’s Bag of Tricks”

Page 60: Do cheaters prosper? Understanding the rules of application development

Goals of “Cheating”

Cost to Deliver

Probability of Request

Low

High

Expensive

Rare

Free

Frequent Identified ProblemExpensive and frequent.

Page 61: Do cheaters prosper? Understanding the rules of application development

Cheating Goals

Cost to Deliver

Probability of Request

Low

High

Expensive

Rare

Free

Frequent

Optimization AMethod to reduce cost of delivery.

Page 62: Do cheaters prosper? Understanding the rules of application development

Cheating Goals

Cost to Deliver

Probability of Request

Low

High

Expensive

Rare

Free

Frequent

Optimization BMethod to reduce frequency of requests.

Page 63: Do cheaters prosper? Understanding the rules of application development

Cheating Goals

Cost to Deliver

Probability of Request

Low

High

Expensive

Rare

Free

Frequent

Optimization A + BCombination reduces cost and frequency.

Page 64: Do cheaters prosper? Understanding the rules of application development

Real-World Examples

Page 65: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Weather Widget

Expensive

Rare

Free

Frequent

ImplementedFetch from API on demandand reformat into widget.

Page 66: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Weather Widget

Expensive

Rare

Free

Frequent

ImplementedFetch from API on demandand reformat into widget.

PopularityWidget used by largepercentage of users.

Page 67: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Weather Widget

Expensive

Rare

Free

Frequent

ImplementedFetch from API on demandand reformat into widget.

CachedWidget data cached andre-used for different users.

PopularityWidget used by largepercentage of users.

Page 68: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Financial Blog

Expensive

Rare

Free

Frequent

Stock SolutionImages are loaded on demandwithout any processing.

Page 69: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Financial Blog

Expensive

Rare

Free

Frequent

Stock SolutionImages are loaded on demandwithout any processing.

PopularityBlog becomes very populardue to publicity.

Page 70: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Financial Blog

Expensive

Rare

Free

Frequent

Stock SolutionImages are loaded on demandwithout any processing.

PopularityBlog becomes very populardue to publicity.

Content ShiftLarge, detailed charts nowa common feature on blog.

Page 71: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Financial Blog

Expensive

Rare

Free

Frequent

Stock SolutionImages are loaded on demandwithout any processing.

PopularityBlog becomes very populardue to publicity.

Content ShiftLarge, detailed charts nowa common feature on blog.

Solution 1Lazy-load images further down page.

Page 72: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Financial Blog

Expensive

Rare

Free

Frequent

Stock SolutionImages are loaded on demandwithout any processing.

PopularityBlog becomes very populardue to publicity.

Content ShiftLarge, detailed charts nowa common feature on blog.

Solution 2Host images on cloud.

Solution 1Lazy-load images further down page.

Page 73: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Financial Blog

Expensive

Rare

Free

Frequent

Stock SolutionImages are loaded on demandwithout any processing.

PopularityBlog becomes very populardue to publicity.

Content ShiftLarge, detailed charts nowa common feature on blog.

Solution 1Lazy-load images further down page.

Solution 2Host images on cloud.

Solution 3Create smaller inline images.

Page 74: Do cheaters prosper? Understanding the rules of application development

Specific Strategies

Page 75: Do cheaters prosper? Understanding the rules of application development

Wait Less

• Work to minimize perceived wait.

• Make things appear instantly.

• Don’t block, lock up, or stall.

• Flip client state immediately, handle in background.

Page 76: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Wait Less

Expensive

Rare

Free

Frequent

Target Zone

“Add User Comment”Frequent operation but requires some heavy processing to apply correctly, complicated by convoluted business logic.

Page 77: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Wait Less

Expensive

Rare

Free

Frequent

Client State Directly AlteredShow result of user action immediately, actually process in background.

Page 78: Do cheaters prosper? Understanding the rules of application development

Wait More

• Make things appear important.

• Keep user informed: spinners, progress bars.

• Keep delay proportional to significance.

• Can avoid really expensive requests by being annoying.

Page 79: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Wait More

Expensive

Rare

Free

Frequent

Target Zone“Preview My Book”Requesting too many previews can cause severe server load issues.

Page 80: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Wait More

Expensive

Rare

Free

Frequent

“Your Book is Queued”Delayed gratification.

More ConsiderationPeople less likely to engagefeature needlessly.

Page 81: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Wait More

Expensive

Rare

Free

Frequent

Target Zone

“Find Best Flight”Might be trivial to calculate, but perceived value is very high.

Page 82: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Wait More

Expensive

Rare

Free

Frequent

“Calculating Results...”Artificial delay makes task seem significant, system more powerful.

Page 83: Do cheaters prosper? Understanding the rules of application development

Load Less

• Fetching things on demand.

• “Lazy loading”

• Ideal for resources that might not be seen.

• Refrigerator light principle: Always seems on.

Page 84: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Load Less

Expensive

Rare

Free

Frequent

Target Zone

“Blog Page, Post N”Things that are requestedbut not always utilized.

Page 85: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Load Less

Expensive

Rare

Free

Frequent

Lazy LoadingPuts of loading a resourceuntil actually required.

Page 86: Do cheaters prosper? Understanding the rules of application development

Load More

• Fetching resources ahead of time.

• “Eager loading”

• Ideal for resources that will probably be seen.

• Boy-scout principle: Be prepared.

Page 87: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Load More

Expensive

Rare

Free

Frequent

Target Zone “Site Icons”Many, many requests for tiny, inexpensive resources can add up.

Page 88: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Load More

Expensive

Rare

Free

Frequent

Asset BundlingCreate single asset that can be used to render all icons.

High Aggregate CostRequesting many tiny resourcescan be expensive.

Site IconsVery large number of small files.

Page 89: Do cheaters prosper? Understanding the rules of application development

Saving Less

• Trim, crop, shrink.

• Strip out redundant or duplicated content.

• Define and enforce limitations.

• One size fits all instead of uncertainty.

• Consider rendering on demand.

Page 90: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Saving Less

Expensive

Rare

Free

Frequent

Target Zone

“Upload Photo”Users upload full-sized photos when only smaller versions are ever actually displayed.

Page 91: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Saving Less

Expensive

Rare

Free

Frequent

Reduce Size, CompressShrinking to sizes required by actual use cases, compressed to an acceptable level of quality.

Page 92: Do cheaters prosper? Understanding the rules of application development

Saving More

• Make copies of things in different formats.

• A form of “caching”, “pre-rendering”

• De-normalize your data.

• Optimize structure around retrieval patterns.

• Try and have everything important ready instantly.

Page 93: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Saving More

Expensive

Rare

Free

Frequent

Target Zone

“Image Variants by Size”Images are used at various fixed sizes, each needing some processing to render.

Page 94: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Saving More

Expensive

Rare

Free

Frequent

Pre-RenderingReduces frequency of requestsrequiring heavy processing.

Page 95: Do cheaters prosper? Understanding the rules of application development

Cache More

• Fastest database call is the one never made.

• Pre-cache when you have the data on hand.

• Reuse and recycle expensive results.

• Let your client cache images, scripts, pages.

• Learn to love the “expires” feature.

Page 96: Do cheaters prosper? Understanding the rules of application development

Target Zone

Cost to Deliver

Probability of Request

Low

High

Cache More

Expensive

Rare

Free

Frequent

Target Zone

High Frequency + CostCache anything you can.

Target Zone

High FrequencyCache if you can.

High CostCache if likely to be used more than once.

Page 97: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Cache More

Expensive

Rare

Free

Frequent

“Friends of My Friends” Database QueryResult unlikely to change except in specific circumstances. Tricky to compute, easy to cache.

Page 98: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Cache More

Expensive

Rare

Free

Frequent

“Video Effects Preview”Result of preview saved temporarily.

First Request

Second Request

Page 99: Do cheaters prosper? Understanding the rules of application development

Cache Less

• Tuning your database can make caching redundant.

• Caches can make updates take longer.

• Cache invalidation can be really hard.

• Cache mistakes can be really embarrassing.

• Running without a cache leaves you with headroom.

Page 100: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Cache Less

Expensive

Rare

Free

Frequent

Target Zone

“Premature Optimization”Hiding real costs, creating hidden liabilities.

Page 101: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Cache Less

Expensive

Rare

Free

Frequent Original ImplementationExpensive and slow.

Caching OpportunityPotential performance gain.

Cached ResultQuick and easy fix.

Refactoring Without CacheSolves actual performance problem.

Page 102: Do cheaters prosper? Understanding the rules of application development

Distribute More

• Content distribution networks.

• Clustered databases, data replication.

• Client-side storage, content bundles.

• Push data closer to users.

• “Edge caching”

Page 103: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Distribute More

Expensive

Rare

Free

Frequent

Target Zone

“Server-Side Content”User provided content is stored on your application servers, storage and retrieval is getting overwhelming.

Page 104: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Distribute More

Expensive

Rare

Free

Frequent

Server Hosted ResourceStored on server, transmissionimpedes other server operations.

CDN Hosted ResourceNo effort required to retainand deliver to client.

Page 105: Do cheaters prosper? Understanding the rules of application development

Distribute Less

• Keep data and content local.

• Self-hosted databases instead of cloud-hosted.

• “Dumb client, smart server” applications.

• Way more control over structure, strategy, technology.

Page 106: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Distribute Less

Expensive

Rare

Free

Frequent

Target Zone

“Cloud Hosted Metrics Database”Slow, unresponsive API, charged per query.

Page 107: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Distribute Less

Expensive

Rare

Free

Frequent

Remote Cloud ServiceTakes hundreds of API calls.

Local Data WarehouseTakes a few SQL queries.

Page 108: Do cheaters prosper? Understanding the rules of application development

Purge More

• Delete data no longer used.

• Archive to cheaper storage systems.

• Generate on demand.

• Less data equals less overhead.

• Minimalist principle.

Page 109: Do cheaters prosper? Understanding the rules of application development

Target Zone

Cost to Deliver

Probability of Request

Low

High

Purge More

Expensive

Rare

Free

Frequent

“Outdated, Detailed User Metrics Data”Expensive to retain, not likely to get used.

Page 110: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Purge More

Expensive

Rare

Free

Frequent

DeletedNobody will miss it.

Page 111: Do cheaters prosper? Understanding the rules of application development

Purge Less

• Dump it on the cloud, forget about it.

• Keep things cached longer.

• Pre-render instead of render on demand.

• Long-tail: Sometimes unpopular things matter.

Page 112: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Purge Less

Expensive

Rare

Free

FrequentSave Alternate FormatsAlso store as XML or JSON, exactly sent by API. High Aggregate Cost

Requests for unrelatedresources can add up.

“Movie Actors”Extensive library of movies, but queries aren’t predictable.

Page 113: Do cheaters prosper? Understanding the rules of application development

Compress More

• Lossless or lossy compression.

• Use deflate (gzip) for transfers.

• Aggressively minify scripts.

Page 114: Do cheaters prosper? Understanding the rules of application development

Target ZoneCost to Deliver

Probability of Request

Low

Compress More

Expensive

Rare

FreeAlmost AnythingMost resources benefit from some form of compression.

Frequent

Page 115: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

Compress More

Expensive

Rare

Free

Frequent

Text ResourceSome things compress really well.

JPEG Image ResourceSome things can’t be compressed much more without damage.

Page 116: Do cheaters prosper? Understanding the rules of application development

Compress Less

• Keep data in pure, raw form.

• Databases can’t interact with compressed data.

• Serialized or compressed data can’t be queried.

• Some databases love JSON or key-value types.

Page 117: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Compress Less

Expensive

Rare

Free

Frequent

“User Profile Data”Hundreds of arbitrary fields, stored as JSON.

Store as Raw JSONSlightly higher write and retrieval cost.Query JSON in DB

Much lower query cost.

Page 118: Do cheaters prosper? Understanding the rules of application development

Index More

• Every query has a cost.

• Examine access patterns, index accordingly.

• A query without an index: painful.

• A query with a tuned index: bliss.

• Indexes massively reduce retrieval time.

Page 119: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

Index More

Expensive

Rare

Free

Frequent

“Message Board Table”Queried very frequently, indexing is vital.

Aggressive IndexingUse index to reduce read cost.

Page 120: Do cheaters prosper? Understanding the rules of application development

Index Less

• Every index makes writes more expensive.

• Indexes don’t always get used.

• Some indexes you might want but not need.

• Awkward but fast can be better than easy but slow.

Page 121: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

Index Less

Expensive

Rare

Free

Frequent

Aggressive IndexingWrites are significantly more expensive.

“User Activity Table”More writes than reads.

Page 122: Do cheaters prosper? Understanding the rules of application development

Multitask More

• Do things in parallel.

• Break down dependencies, avoid contention.

• Distribute work across many systems.

• Map-reduce doesn’t have to be hard.

Page 123: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Multitask More

Expensive

Rare

Free

Frequent“Render Page”Smaller scale task is easy todelegate to many workers.

“Render Album Preview”Each page is an independent, but the final book needs to be one file.

Perceived ResultProcessing time massively reduced.

Page 124: Do cheaters prosper? Understanding the rules of application development

Multitask Less

• Stream things in sequentially.

• Keep load on server light.

• Keeps more network resources available.

• Buffer requests and process casually.

Page 125: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Multitask Less

Expensive

Rare

Free

Frequent

“Sync Calendar Entries”Operation that’s expected to take considerable time can be delayed.

Background TasksCreate a simple work queue to minimize number of parallel operations.

Page 126: Do cheaters prosper? Understanding the rules of application development

Provision More

• Server hardware can be scaled up.

• Desktop/mobile apps can leverage server hardware.

• On-demand cloud services can be awesome.

• No inherent limit on server capability.

• If you can throw hardware at it, maybe do that.

Page 127: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Provision More

Expensive

Rare

Free

Frequent Relatively ExpensiveUses high percentage of CPU.

Relatively InexpensiveSame operation on distributed server cluster is no big deal.

Page 128: Do cheaters prosper? Understanding the rules of application development

Provision Less

• Keep your application footprint lean.

• Don’t burn through CPU and battery.

• Don’t use tons of memory.

• Smaller apps load faster, don’t get kicked out as often.

• Smaller server clusters easier to tune and manage.

Page 129: Do cheaters prosper? Understanding the rules of application development

Cost to Deliver

Probability of Request

Low

High

Provision Less

Expensive

Rare

Free

Frequent

“Upload All Photos on Phone”Interrupts application flow, stalls, heavy CPU usage.

Batched OperationsSplit up task into smaller, low-impact tasks.

Page 130: Do cheaters prosper? Understanding the rules of application development

Breaking Rules

Page 131: Do cheaters prosper? Understanding the rules of application development

“Cheating”

Page 132: Do cheaters prosper? Understanding the rules of application development

Focus on the effects.

Page 133: Do cheaters prosper? Understanding the rules of application development

Figure the rest out.

Page 134: Do cheaters prosper? Understanding the rules of application development

Scott Tadman

twg.ca @ceben @twg

THANK YOUScott Tadman / Dom Bortolussi

twg.ca@tadmanter @dombort @twggithub.com/[email protected]