Skip to content

Instantly share code, notes, and snippets.

@leppie
Last active July 19, 2016 12:57
Show Gist options
  • Save leppie/450d054c568d8919c61eddfe32e1c1ae to your computer and use it in GitHub Desktop.
Save leppie/450d054c568d8919c61eddfe32e1c1ae to your computer and use it in GitHub Desktop.
Creating a high performance Azure web app on the cheap (WIP)

Goal

Get the best possible performance from the Developer Program Benefit subscription on Azure. Around R450 of Azure credits per month for free.

Using

  • App service - D1 Shared (Free is OK, but only 160MB data a day, so AppInsights will eat that up very quickly. Costs R166, above $$$)
  • Database - B Basic (cheap! only R86, good value for money)

Tips

SQL

  • Optimize, optimize, optimize! You only get 30ms/sec CPU time before maxing out allowance
    • Avoid scans, prefer seeks
    • Statistics will screw you when it can though
  • Use MARS
    • Forget about using around connections!
    • Saves keystrokes!
  • Use Pooling
    • Not the default!
    • Not using pooling costs 30ms+ connection open durations
  • Set Max pooling to 30
    • This is the max you will get
  • Set connection timeout to 60 (seconds)
    • If you care about losing connections
  • Use query store (a lot!)
    • Defaults suck!
    • Use Top Resource Consumers, select Average, sort by Execution count
  • Use one SQL connection per request, open lazy, close eager
  • EF is not that bad, but use Dapper and SQL views for max performance
    • Views make SQL dev easier, and you can easily see query plans and test predicates
  • Use batch queries (in Dapper QueryMultiple)
    • A good 2-3ms overhead for every time you call ExecuteXXX

Web

  • Precompile web pages
    • No one likes slow starting sites
  • Use async (but not really required)
    • If you dont mind the latency
  • Compile for Release
    • But include PDB's for debugging and stacktraces
  • Cache what you can when memory limits allow it (need to look at old Azure portal for this)
    • SQL will eat you
    • Even a short cache of 1 second will prevent SQL from getting bogged down under load
  • AppInsights can be helpful (setup a 5 minute, 5 location 'uptime' job)
  • Keep server reponse times as low as possible, lower the better (ideally < 10ms)
    • You can expect a max of 400 requests a second for a non-db page
  • If not using async, use .NET 3.5 for an extra free 100+ MB RAM
    • Helpful for caching

General

  • Use free Cloud load testing (I generally do 125 users over 2 minutes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment