Your SlideShare is downloading. ×
Tablas y almacenamiento en windows azure
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Tablas y almacenamiento en windows azure

578
views

Published on

En este presentación vemos los conceptos principales y mejores prácticas de tablas en Windows Azure. …

En este presentación vemos los conceptos principales y mejores prácticas de tablas en Windows Azure.

Saludos,


0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
578
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Ing. Eduardo Castro, PhD Comunidad Windows ecastro@grupoasesor.net http://ecastrom.blogspot.com
  • 2. 1. Overview of Windows Azure Tables 2. Patterns and Practices for Windows Azure Tables 3. Overview of Windows Azure Queues 4. Patterns and Practices for Windows Azure Queues 5. Q&A 2
  • 3. Tables – Provide structured storage. A TableProvide structured storage. A Table is a set of entities, which contain a set ofis a set of entities, which contain a set of propertiesproperties Queues – Provide reliable storage and delivery of messages for an application Blobs – Provide a simple interface for storing named files along with metadata for the file Drives – Provides durable NTFS volumes for Windows Azure applications to use (new) 3
  • 4. Provides Structured Storage Massively Scalable Tables Billions of entities (rows) and TBs of data Can use thousands of servers as traffic grows Highly Available & Durable Data is replicated several times Familiar and Easy to use API ADO.NET Data Services – .NET 3.5 SP1 .NET classes and LINQ REST – with any platform or language 4
  • 5. Email =… Name = … Email =… Name = … Genre =… Title = … Genre =… Title = … 5
  • 6. Table A storage account can create many tables Table name is scoped by account Set of entities (i.e. rows) Entity Set of properties (columns) Required properties PartitionKey, RowKey and Timestamp 6
  • 7. PartitionKey & RowKey Uniquely identifies an entity Defines the sort order Use them to scale your application Timestamp Read only Optimistic Concurrency 7
  • 8. PartitionKey Used to group entities in the table into partitions A table partition All entities with same partition key value Unit of scale Control entity locality Row key provides uniqueness within a partition 8
  • 9. PartitionKey (Category) RowKey (Title) Timestamp ReleaseDat e Action Fast & Furious … 2009 Action The Bourne Ultimatum … 2007 … … … … Animation Open Season 2 … 2009 Animation The Ant Bully … 2006 PartitionKey (Category) RowKey (Title) Timestamp ReleaseDat e Comedy Office Space … 1999 … … … … SciFi X-Men Origins: Wolverine … 2009 … … … … War Defiance … 2008 PartitionKey (Category) RowKey (Title) Timestamp ReleaseDat e Action Fast & Furious … 2009 Action The Bourne Ultimatum … 2007 … … … … Animation Open Season 2 … 2009 Animation The Ant Bully … 2006 … … … … Comedy Office Space … 1999 … … … … SciFi X-Men Origins: Wolverine … 2009 … … … … War Defiance … 2008 9
  • 10. Table Create Query Delete Entities Insert Update Merge – Partial Update Replace – Update entire entity Delete Query Entity Group Transaction (new)
  • 11. Define the schema as a .NET class 11 [DataServiceKey("PartitionKey", "RowKey")] public class Movie { /// <summary> /// Category is the partition key /// </summary> public string PartitionKey { get; set; } /// <summary> /// Title is the row key /// </summary> public string RowKey { get; set; } public DateTime Timestamp { get; set; } public int ReleaseYear { get; set; } public string Language { get; set; } public string Cast { get; set; } }
  • 12. 12 StorageCredentialsAccountAndKey credentials = new StorageCredentialsAccountAndKey( “myaccount", “myKey"); string baseUri = "http://myaccount.table.core.windows.net"; CloudTableClient tableClient = new CloudTableClient(baseUri, credentials); tableClient.CreateTable(“Movies"); TableServiceContext context = tableClient.GetDataServiceContext(); CloudTableQuery<Movie> q = (from movie in context.CreateQuery<Movie>(“Movies") where movie.PartitionKey == “Action" && movie.RowKey == "The Bourne Ultimatum" select movie).AsTableServiceQuery<Movie>(); Movie movieToUpdate = q.FirstOrDefault(); // Update movie context.UpdateObject(movieToUpdate); context.SaveChangesWithRetries(); // Add movie context.AddObject(new Movie(“Action" , movieToAdd)); context.SaveChangesWithRetries();
  • 13. 1. Overview of Windows Azure Tables 2. Patterns and Practices for Windows Azure Tables 3. Overview of Windows Azure Queues 4. Patterns and Practices for Windows Azure Queues 5. Q & A 13
  • 14. 14
  • 15. 15
  • 16. 16 PartitionKey (Account name) RowKey (Title) Category … moviesonline 12 Rounds Action … moviesonline A Bug’s Life Animation … 100,000,000 more rows … … … moviesonline Office Space Comedy … moviesonline Platoon War … 50,000,000 more rows … … … moviesonline WALL-E Animation …
  • 17. PartitionKey (Account name) RowKey (Title) Category … moviesonline 12 Rounds Action … moviesonline A Bug’s Life Animation … 100,000,000 more rows … … … moviesonline Office Space Comedy … moviesonline Platoon War … 50,000,000 more rows … … … moviesonline WALL-E Animation … ClientClientClientClient 17
  • 18. PartitionKey (Category) RowKey (Title) Action Fast & Furious … 10000 more Action movies Action The Bourne Ultimatum … 100000 more Action & Animation movies Animation Open Season 2 … 100000 more Animation movies Animation The Ant Bully Comedy Office Space … 1000000 more Comedy & SciFi movies SciFi Star Trek … 100000 more SciFi & War movies … 100000 more War movies War Defiance ClientClientClientClient 18 PartitionKey (Category) RowKey (Title) Action Fast & Furious … 10000 more Action movies Action The Bourne Ultimatum … 100000 more Action & Animation movies Animation Open Season 2 … 100000 more Animation movies Animation The Ant Bully Comedy Office Space … 1000000 more Comedy & SciFi movies SciFi Star Trek … 100000 more SciFi & War movies … 100000 more War movies War Defiance
  • 19. 19
  • 20. PartitionKey (Timestamp) Properties 2009-11-15 02:00:01 … 2009-11-15 02:00:11 … 100000 more rows … 2009-11-17 05:40:01 … 2009-11-17 05:40:01 … 80000 more rows … 2009-11-17 12:30:00 … 2009-11-17 12:30:01 … ApplicationsApplications ClientClient 2009-11-17 12:30:01 … 2009-11-17 12:30:02 … 2009-11-17 12:30:03 … 20
  • 21. PartitionKey (ID_Timestamp) Properties 01_2009-10-12 05:10:00 … … … 100000 more rows … 09_2009-11-15 12:31:00 … … … 20000000 more rows … 10_2009-10-05 05:10:10 … 5000000 more rows … … … 900000 more rows … 19_2009-11-17 12:20:02 … ApplicationsApplicationsApplicationsApplications ClientClient 15_2009-11-17 12:30:01 … 09_2009-11-17 12:30:22 … 19_2009-11-17 12:30:10 … 01_2009-11-17 12:30:01 … 21
  • 22. 22
  • 23. PartitionKey (Category) RowKey (Title) Action Fast & Furious … 10000 more Action movies Action The Bourne Ultimatum … 100000 more Action & Animation movies Animation Open Season 2 … 100000 more Animation movies Animation The Ant Bully Comedy Office Space … 1000000 more Comedy & SciFi movies SciFi Star Trek … 100000 more SciFi & War movies … 100000 more War movies War Defiance ClientClient 23
  • 24. ClientClient PartitionKey (Category) RowKey (Title) Rating Action Fast & Furious 5 … 999 more movies rated > 4 … … Action and Anim. movies here with rating < 4 … Animation A Bug’s life 2 … 100 more movies < 4 here … Animation The Ant Bully 3 Comedy Are we there yet? 2 … More movies here … Comedy Office Space 5 … 800000 more movies here … Drama A Beautiful Mind 5 … 1200000 more movies here … War Defiance 4 24 Returns 1000 movies Partition range boundary hit Return continuation
  • 25. ClientClient PartitionKey (Category) RowKey (Title) Rating Action Fast & Furious 5 … More movies here … Comedy Office Space 5 … More movies here … Documentary Planet Earth 4 … More movies here Drama Seven Pounds 4 Horror Saw 5 3 … More movies here … Music 8 Mile 2 … More movies here … SciFi Star Trek 5 … More movies here … 25
  • 26. 26
  • 27. 27
  • 28. 28
  • 29. 29
  • 30. 30
  • 31. PartitionKey (AccountID) RowKey (Kind_*) Kind TotalRentals Name Address CheckOutOn Title DueOn … … … … … … … … … Sally A_Sally Account 8 Sally Field Ann Arbor, MI Sally R_Jaws Rental 2009/11/16 Jaws 2009/11/20 Sally R_Taxi Rental 2009/11/16 Taxi 2009/11/20 … … … … … … … … … 31
  • 32. 32
  • 33. 1. Overview of Windows Azure Tables 2. Patterns and Practices for Windows Azure Tables 3. Overview of Windows Azure Queues 4. Patterns and Practices for Windows Azure Queues 5. Q & A 33
  • 34. Queue are performance efficient, highly available and provide reliable message delivery Simple, asynchronous work dispatch Programming semantics ensure that a message can be processed at least once Access is provided via REST 34
  • 35. 35
  • 36. An account can create many queues Queue Name is scoped by the account A Queue contains messages No limit on number of messages stored in a queue Set a limit for message expiration Messages Message size <= 8 KB To store larger data, store data in blob/entity storage, and the blob/entity name in the message Message now has dequeue count 36
  • 37. Queue Create Queue Delete Queue List Queues Get/Set Queue Metadata Messages Add Message (i.e. Enqueue Message) Get Message(s) (i.e. Dequeue Message) Peek Message(s) Delete Message 37
  • 38. 38 CloudQueueClient queueClient = new CloudQueueClient(baseUri, credentials); CloudQueue queue = queueClient.GetQueueReference("test1"); queue.CreateIfNotExist(); //MessageCount is populated via FetchAttributes queue.FetchAttributes(); CloudQueueMessage message = new CloudQueueMessage("Some content"); queue.AddMessage(message); message = queue.GetMessage(TimeSpan.FromMinutes(10) /*visibility timeout*/); //Process the message here … queue.DeleteMessage(message);
  • 39. 1. Overview of Windows Azure Tables 2. Patterns and Practices for Windows Azure Tables 3. Overview of Windows Azure Queues 4. Patterns and Practices for Windows Azure Queues 5. Q & A 39
  • 40. 2 1 2 1 1 1 1 1 C1 C1 C2 C2 1 1 1 1 2 1 2 1 334 0 4 0 Producers Consumers P2 P2 P1 P1 3 0 3 0 2. GetMessage(Q, 30 s)  msg 2 1. GetMessage(Q, 30 s)  msg 1 1 1 1 1 2 1 2 1 40 1 0 1 0 2 0 2 0
  • 41. C1 C1 C2 C2 34 0 4 0 Producers Consumers P2 P2 P1 P1 1 1 1 1 2 1 2 1 2. GetMessage(Q, 30 s)  msg 2 3. C2 consumed msg 2 4. DeleteMessage(Q, msg 2) 7. GetMessage(Q, 30 s)  msg 1 1. GetMessage(Q, 30 s)  msg 1 5. C1 crashed 1 1 1 1 2 1 2 1 6. msg1 visible 30 s after Dequeue3 0 3 0 41 1 2 1 2 1 1 1 1 1 2 1 2
  • 42. C1 C1 C2 C2 34 0 4 0 Producers Consumers P2 P2 P1 P1 1 2 1 2 2. Dequeue(Q, 30 sec)  msg 2 3. C2 consumed msg 2 4. Delete(Q, msg 2) 7. Dequeue(Q, 30 sec)  msg 1 8. C2 crashed 1. Dequeue(Q, 30 sec)  msg 1 5. C1 crashed 10. C1 restarted 11. Dequeue(Q, 30 sec)  msg 1 12. DequeueCount > 2 13. Delete (Q, msg1) 1 2 1 2 6. msg1 visible 30s after Dequeue 9. msg1 visible 30s after Dequeue 3 0 3 0 42 1 3 1 3 1 2 1 2 1 3 1 3
  • 43. 43
  • 44. 44
  • 45. http://comunidadwindows.org http://ecastrom.blogspot.com http://www.sqlazurelabs.com http://www.microsoft.com/windowsazure/ http://sql.azure.com/