0
Top 5 Things Developers Should Know @                 SQL Azure        By Ike Ellis        http://www.ellisteam.net       ...
Before the DragonsQuick Demo: How to Sign Up• Free Accounts   – BizSpark   – MSDN Subscription   – 30 day trial     • Bing...
Architecture
Before the Dragons: Architecture -Logical/Physical Databases/Servers
Dragon #1: The ConnectionString
Your SQL Server    Your    AppChange Connection String                           SQL Azure
5 Things Make Up a Connection String• What are they?
5 Things Make Up a Connection String• What are they?  – UserName  – Password  – Database(Catalog)  – ServerName  – Provide...
#1 ConnectionString<add name="FlashcardEntities"connectionString="metadata=res://*/Models.FlashcardData.csdl|res://*/Model...
Connection Providers• Use ADO.NET, ODBC, PHP (NOT OLE DB)   – Client libraries pre-installed in Azure roles   – Support fo...
Typical ADO.NET Connection.Open()try
{
      using (SqlConnection conn = new SqlConnection(sqlConnectionString))
       {
...
New Connection.Open())string sqlContext = string.empty;try
{
        using (SqlConnection conn = new SqlConnection(sqlConn...
GetSqlContextInfo•   http://blogs.msdn.com/b/bartr/archive/2010/06/18/sql-azure-connection-    retry.aspx?utm_source=feedb...
Dragon #2: Throttling, Disaster Recovery, &            Some New Errors
Throttling
Throttling• Throttling Service   – Protects a machine from sustained high usage of     system resources   – Evaluate actua...
Throttling Scenario #1• Customer A uses 30% of the CPU on the server• Customer B comes in and starts using 70% of the  CPU...
Throttling Scenario #2• Customer B uses 70% of the CPU on the server• Customer A comes in and uses 30% of the CPU on  the ...
Throttling Class – Trace Young• http://social.technet.microsoft.com/wiki/contents/ar  ticles/sql-azure-performance-and-ela...
Another Reason We Need Retry Code =Disaster Recovery/Database Replicas
Dragon #2: Some New Errors1.   40550 - Session has been terminated because it has acquired too many locks. Try reading or ...
Dragon #3: Tooling• SQL Azure Database Manager   – Silverlight Tool• SSMS 2008 R2   – Standard Tool
Dragon #4: DB Migration•   SSIS•   BCP•   SSMS – Generate Scripts•   DEMO: SQL Azure Migration Wizard
Dragon #5: Performance Tuning•   Let’s get this out of the way – What we don’t have:•   no sql error log•   no sql profile...
SQL Azure Performance Guide1) Missing Indexes or better indexes      1) Use DMVs      2) Use Query Plans2) Covering indexe...
What I Didn’t Cover, But You MightWant to Research•   Pricing•   Included/Excluded Features•   Product Roadmap•   SQL Azur...
Good Resources•   SQL Azure Team Blog & Twitter      – http://blogs.msdn.com/b/sqlazure/      – Twitter: @sqlazure•   Insi...
Red Gate Tools for SQL Azure• SQL Compare• SQL Data Compare• SQL Azure Backup
DBA role places more focus on logical management• SQL Azure focus on logical administration   – Schema creation and manage...
Database Backup Today = Full Copy
Backup / Restore – Database Copy• CREATE DATABASE TechBio2 AS COPY OF servername.  TechBio• Select * from sys.dm_database_...
Hope for the Future
Until Then• Red-Gate has a tool   – No Point In Time Restore   – Brings the database on-premise! And Restores     from on-...
Contact Ike•   Email: ike@ellisteam.net•   Twitter: @ike_ellis•   Website: http://www.ellisteam.net•   Phone: 619.922.9801...
Developing on SQL Azure
Developing on SQL Azure
Developing on SQL Azure
Developing on SQL Azure
Developing on SQL Azure
Developing on SQL Azure
Developing on SQL Azure
Developing on SQL Azure
Developing on SQL Azure
Developing on SQL Azure
Developing on SQL Azure
Developing on SQL Azure
Upcoming SlideShare
Loading in...5
×

Developing on SQL Azure

1,434

Published on

This is the slide deck from my SQL In The City presentation in LA on October

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,434
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
10
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • This is you
  • You are very good looking.
  • You are sailing safely on the waters of an ON PREMISE SQL SERVER….You know these waters…and they are comfortable.
  • What’s that up ahead?
  • It’s a cloud! A SQL Azure Cloud! And it look unavoidable…yet fun! You decide to consult your map, to learn more about what might be in that cloud.
  • That dragon on the map looks scary!
  • But when you look closer at the real dragon, you find that it’s not so scary…in fact, kind of harmless….
  • Transcript of "Developing on SQL Azure"

    1. 1. Top 5 Things Developers Should Know @ SQL Azure By Ike Ellis http://www.ellisteam.net @ike_ellis ike@ellisteam.net P: 619.922.9801
    2. 2. Before the DragonsQuick Demo: How to Sign Up• Free Accounts – BizSpark – MSDN Subscription – 30 day trial • Bing SQL Azure 30 day trial….there are coupons and instructions. • Look on the SQL Azure Team Blog – Remember: Microsoft wants you to use this, there’s a way to try it for free…
    3. 3. Architecture
    4. 4. Before the Dragons: Architecture -Logical/Physical Databases/Servers
    5. 5. Dragon #1: The ConnectionString
    6. 6. Your SQL Server Your AppChange Connection String SQL Azure
    7. 7. 5 Things Make Up a Connection String• What are they?
    8. 8. 5 Things Make Up a Connection String• What are they? – UserName – Password – Database(Catalog) – ServerName – ProviderName
    9. 9. #1 ConnectionString<add name="FlashcardEntities"connectionString="metadata=res://*/Models.FlashcardData.csdl|res://*/Models.FlashcardData.ssdl|res://*/Models.FlashcardData.msl;provider=System.Data.SqlClient;provider connectionstring=&quot;Data Source=etnejn2aev.database.windows.net;Initial Catalog=flashcards;IntegratedSecurity=False;User ID=***(username@servername);Password=*******;MultipleActiveResultSets=True;Encrypt=True(negotiated);TrustServerCertificate=False&quot;" providerName="System.Data.EntityClient" />
    10. 10. Connection Providers• Use ADO.NET, ODBC, PHP (NOT OLE DB) – Client libraries pre-installed in Azure roles – Support for ASP.NET controls• Clients connect directly to a database – Cannot hop across DBs (no USE) – May need to include <login>@<server> – Use familiar tools (sqlcmd, osql, SSMS, etc) – Use connection pooling for efficiency• SSMS 2008 R2 can connect – http://blogs.msdn.com/ssds/archive/2009/11/11/9921041.aspx• SSRS, SSIS, SSAS can all connect to SQL Azure using the right provider.
    11. 11. Typical ADO.NET Connection.Open()try
{
 using (SqlConnection conn = new SqlConnection(sqlConnectionString))
 {
 using (SqlCommand cmd = new SqlCommand(sqlStatement, conn))
 {
 conn.Open(); using (SqlDataReader dr = cmd.ExecuteReader())
 {
 while (dr.Read())
 {
 }
 }
 }
 }
}catch (SqlException ex)
{
 SxpLog.WriteSqlException(ex, "some", "other", "data");
}
    12. 12. New Connection.Open())string sqlContext = string.empty;try
{
 using (SqlConnection conn = new SqlConnection(sqlConnectionString))
 {
 using (SqlCommand cmd = new SqlCommand(sqlStatement, conn))
 {
 sqlContext = GetSqlContextInfo(conn); using (SqlDataReader dr = cmd.ExecuteReader())
 {
 while (dr.Read())
 {
 }
 }
 }
 }
}catch (SqlException ex)
{
 SxpLog.WriteSqlException(ex, sqlContext, "some", "other", "data");
}
    13. 13. GetSqlContextInfo• http://blogs.msdn.com/b/bartr/archive/2010/06/18/sql-azure-connection- retry.aspx?utm_source=feedburner&utm_medium=twitter&utm_campaign=Feed:+Microsoft/MSDN- Blogs+(MSDN+Blogs)
    14. 14. Dragon #2: Throttling, Disaster Recovery, & Some New Errors
    15. 15. Throttling
    16. 16. Throttling• Throttling Service – Protects a machine from sustained high usage of system resources – Evaluate actual resource usage vs. safe thresholds real-time – Throttle the busiest days first• Throttling shows as connection error 40501 – The service is currently busy. Retry the request after 10 seconds…• Needs Decoding
    17. 17. Throttling Scenario #1• Customer A uses 30% of the CPU on the server• Customer B comes in and starts using 70% of the CPU on the server• Customer B triggers the throttling event• Customer B gets throttled
    18. 18. Throttling Scenario #2• Customer B uses 70% of the CPU on the server• Customer A comes in and uses 30% of the CPU on the server• Customer A triggers the throttling event• Customer B gets throttled
    19. 19. Throttling Class – Trace Young• http://social.technet.microsoft.com/wiki/contents/ar ticles/sql-azure-performance-and-elasticity- guide.aspx#Code_Sample_Decoding_SQL_Azure_Rea son_Codes
    20. 20. Another Reason We Need Retry Code =Disaster Recovery/Database Replicas
    21. 21. Dragon #2: Some New Errors1. 40550 - Session has been terminated because it has acquired too many locks. Try reading or modifying fewer rows in a single transaction. (Greater than 1,000,000 locks)2. 40551 - Session has been terminated because of excessive TempDB Usage(TempDB is only allowed to be 5GB in size)3. 40552 - Session used too much of the transaction log. try modifying fewer rows in a single transaction. (Transaction consuming excessive log resources are terminated. The max permitted log size for a single transaction is 1GB)4. 40544 - Database reached its max size. Switched to read-only5. 40553 - Session is terminated because of excessive memory usage. (Where there is memory contention, sessions consuming greater than 16MB for more than 20 seconds are terminated in the descending order of time the resource has been held)6. 40549 - Session is terminated because of a long running transaction (SQL Azure kills all transactions after 24 hours.)7. 40501 The service is currently busy. Retry the request after 10 seconds. Code: %d (SQL Azure might terminate the transactions and disconnect the sessions when the CPU utilization, input/output I/O latency, and the number of busy workers exceed thresholds.
    22. 22. Dragon #3: Tooling• SQL Azure Database Manager – Silverlight Tool• SSMS 2008 R2 – Standard Tool
    23. 23. Dragon #4: DB Migration• SSIS• BCP• SSMS – Generate Scripts• DEMO: SQL Azure Migration Wizard
    24. 24. Dragon #5: Performance Tuning• Let’s get this out of the way – What we don’t have:• no sql error log• no sql profiler• no pssdiag• no bpa (best practices analyzer)• no xevent• no server side network capture• no mps reports(microsoft product support reports)• Only some DMVs
    25. 25. SQL Azure Performance Guide1) Missing Indexes or better indexes 1) Use DMVs 2) Use Query Plans2) Covering indexes for the WHERE clause3) Can sorting be done on the client?4) Minimize round trips5) Limit records (paging)6) Use Connection Pooling (open connection late, close them early)7) Retry Logic (wait 10 seconds and then retry)8) Catch errors and understand that when azure throws an error, the tran rollback9) Caching and batching - evaluate caching and batching to limit round-trips to the server10) avoid latency - choose a data center nearest to your location11) Trace connections - traced connections using context_info() to troubleshoot connectivity issues12) CALL SUPPORT
    26. 26. What I Didn’t Cover, But You MightWant to Research• Pricing• Included/Excluded Features• Product Roadmap• SQL Azure Reporting• Backup/Restore Options• SQL Azure Data Sync• SQL Azure Odata• Future Differences Between Editions
    27. 27. Good Resources• SQL Azure Team Blog & Twitter – http://blogs.msdn.com/b/sqlazure/ – Twitter: @sqlazure• Inside SQL Azure – Kalen Delaney – http://social.technet.microsoft.com/wiki/contents/articles/inside-sql-azure.aspx• SQL Azure & Entity Framework – Julie Lerman – http://msdn.microsoft.com/en-us/magazine/gg309181.aspx – Doesn’t cover the retry issue.• My Site – Ike Ellis – http://www.ellisteam.net – Twitter: @ike_ellis• .NET ROCKS – SQL Azure Migration Wizard – December, 2009 – http://www.dotnetrocks.com/default.aspx?showNum=512• Scott Klein & Herve Rogerro Book – http://www.amazon.com/Pro-Azure-Experts-Voice- NET/dp/1430229616/ref=sr_1_1?ie=UTF8&qid=1297792245&sr=8-1• MY O’REILLY BOOK IS COMING THIS SPRING! – Yes, it has an animal cover.
    28. 28. Red Gate Tools for SQL Azure• SQL Compare• SQL Data Compare• SQL Azure Backup
    29. 29. DBA role places more focus on logical management• SQL Azure focus on logical administration – Schema creation and management – Query optimization – Security management (Logins, Users, Roles)• Service handles physical management – Automatically replicated with HA “out of box” – Transparent failover in case of failure – Load balancing of data to ensure SLA
    30. 30. Database Backup Today = Full Copy
    31. 31. Backup / Restore – Database Copy• CREATE DATABASE TechBio2 AS COPY OF servername. TechBio• Select * from sys.dm_database_copies• No point in time
    32. 32. Hope for the Future
    33. 33. Until Then• Red-Gate has a tool – No Point In Time Restore – Brings the database on-premise! And Restores from on-premise!
    34. 34. Contact Ike• Email: ike@ellisteam.net• Twitter: @ike_ellis• Website: http://www.ellisteam.net• Phone: 619.922.9801• User Group: http://www.sdtig.com• DevelopMentor Courses: http://www.develop.com
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×