Home
%3CLINGO-SUB%20id%3D%22lingo-sub-1015605%22%20slang%3D%22en-US%22%3EIoT%20Solutions%20and%20Azure%20Cosmos%20DB%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1015605%22%20slang%3D%22en-US%22%3E%3CP%3EHere%20are%20the%202%20main%20reasons%20why%20Azure%20Cosmos%20DB%20is%20great%20for%20in%20IoT%20applications%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ECosmos%20DB%20can%20ingest%20semi-structured%20data%20at%20extremely%20high%20rates.%3C%2FLI%3E%0A%3CLI%3ECosmos%20DB%20can%20serve%20indexed%20queries%20back%20out%20with%20extremely%20low%20latency%20and%20high%20availability.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EFor%20a%20fascinating%20history%20and%20in-depth%20technical%20outline%20of%20Cosmos%20DB%2C%20check%20out%20%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fen-us%2Fblog%2Fazure-cosmos-db-microsofts-globally-distributed-multi-model-database-service%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ethis%20blog%3C%2FA%3E%20by%20Dharma%20Shukla%20Founder%20of%20Azure%20Cosmos%20DB%2C%20Technical%20Fellow%2C%20Microsoft.%3C%2FP%3E%0A%3CP%3EThe%20two%20primary%20IoT%20use%20cases%20for%20Cosmos%20DB%20are%20storing%20device%20telemetry%20and%20managing%20a%20device%20catalog.%20Read%20on%20to%20learn%20key%20details%20and%20catch%20this%20Channel%209%20IoT%20Show%26nbsp%3Bepisode%20with%20Andrew%20Liu%2C%20Program%20Manager%2C%20Cosmos%20DB%20team%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20center%3B%22%3E%3CIFRAME%20src%3D%22https%3A%2F%2Fwww.youtube.com%2Fembed%2FQKdonfbV_0w%22%20width%3D%22560%22%20height%3D%22315%22%20frameborder%3D%220%22%20allowfullscreen%3D%22allowfullscreen%22%20allow%3D%22accelerometer%3B%20autoplay%3B%20encrypted-media%3B%20gyroscope%3B%20picture-in-picture%22%3E%3C%2FIFRAME%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-1053998649%22%20id%3D%22toc-hId-1054773495%22%20id%3D%22toc-hId-1054773495%22%20id%3D%22toc-hId-1054773495%22%20id%3D%22toc-hId-1054773495%22%20id%3D%22toc-hId-1054773495%22%20id%3D%22toc-hId-1054773495%22%20id%3D%22toc-hId-1054773495%22%3EStoring%20device%20telemetry%3C%2FH3%3E%0A%3CP%3EThe%20first%20IoT%20use%20case%20for%20Cosmos%20DB%20is%20storing%20telemetry%20data%20in%20a%20way%20that%20allows%20for%20rapid%20access%20to%20the%20data%20for%20visualization%2C%20post%20processing%20and%20analytics.%3C%2FP%3E%0A%3CP%3EXTO%20Energy%2C%20a%20subsidiary%20of%20ExxonMobil%2C%20uses%20Cosmos%20DB%20for%20this%20exact%20scenario.%20The%20company%20has%2050%2C000%20oil%20wells%20generating%20telemetry%20data%20like%20flow%20rate%20and%20temperature%20at%20a%20high%20throughput.%20With%20lots%20and%20lots%20of%20bytes%2Fsecond%20coming%20in%2C%20XTO%20DB%20uses%20Cosmos%20DB%20because%20of%20its%20fast%2C%20indexed%20data%20store%2C%20partitioning%2C%20and%20automatic%20indexing.%20See%20the%20architecture%20diagram%20below%20showing%20how%20Cosmos%20DB%20fits%20in%20their%20IoT%20solution.%26nbsp%3BNote%20that%20data%20comes%20into%20Azure%20IoT%20Hub.%20Typically%2C%20you%20would%20position%20a%20hot%20store%20(with%20fast%2C%20interactive%20queries)%20and%20cold%20store%20behind%20IoT%20Hub.%20In%20this%20case%2C%20Azure%20Cosmos%20DB%20is%20used%20for%20the%20hot%20store.%20Read%20more%20about%20%3CA%20href%3D%22https%3A%2F%2Fcustomers.microsoft.com%2Fen-us%2Fstory%2Fexxonmobil-mining-oil-gas-azure%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EXTO%20Energy%20use%20of%20Azure%20Cosmos%20DB%20and%20Azure%20IoT%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F157731i5D065E46C86BEEF0%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22CosmosDB%20picture1.png%22%20title%3D%22CosmosDB%20picture1.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--753455814%22%20id%3D%22toc-hId--752680968%22%20id%3D%22toc-hId--752680968%22%20id%3D%22toc-hId--752680968%22%20id%3D%22toc-hId--752680968%22%20id%3D%22toc-hId--752680968%22%20id%3D%22toc-hId--752680968%22%20id%3D%22toc-hId--752680968%22%3EDevice%20catalog%3C%2FH3%3E%0A%3CP%3EA%20second%20IoT%20scenario%20that%20benefits%20using%20Cosmos%20DB%20is%20managing%20a%20device%20catalog%20for%20critical%20processes.%20This%20is%20where%20the%20low%20latency%20and%20%22always%20on%22%20guarantees%20of%20Cosmos%20DB%20comes%20in.%26nbsp%3BLess%20than%2010-ms%20latencies%20for%20both%2C%20reads%20(indexed)%20and%20writes%20at%20the%2099th%20percentile%2C%20all%20around%20the%20world%20and%2099.999%25%20availability%20for%20multi-region%20writes!%3C%2FP%3E%0A%3CP%3EAzure%20Cosmos%20DB%20transparently%20replicates%20your%20data%20across%20all%20the%20Azure%20regions%20associated%20with%20your%20Cosmos%20account.%20Cosmos%20DB%20employs%20multiple%20layers%20of%20redundancy%20for%20your%20data%20managing%20partitioning%20for%20you.%20Learn%20more%20about%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fcosmos-db%2Fhigh-availability%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ECosmos%20DB%20high%20availability.%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EA%20real-life%20scenario%20example%20is%20that%20of%20an%20automobile%20manufacturer%20running%20an%20assembly%20line%20with%20high%20availability%20requirements.%20The%20manufacturer%20drives%20commands%20to%20robots%20that%20manufacture%20the%20cars.%20In%20order%20to%20ensure%20that%20the%20assembly%20line%20never%20stops%2C%20the%20manufacturer%20uses%20Cosmos%20DB%20to%20ensure%20extremely%20high%20availability%20and%20low%20latency.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-1734057019%22%20id%3D%22toc-hId-1734831865%22%20id%3D%22toc-hId-1734831865%22%20id%3D%22toc-hId-1734831865%22%20id%3D%22toc-hId-1734831865%22%20id%3D%22toc-hId-1734831865%22%20id%3D%22toc-hId-1734831865%22%20id%3D%22toc-hId-1734831865%22%3EGetting%20started%20with%20Cosmos%20DB%20for%20IoT%3C%2FH3%3E%0A%3CP%3EThere%20are%20four%20%E2%80%9Cmust-know%E2%80%9D%20aspects%20that%20IoT%20developers%20need%20to%20understand%20to%20work%20with%20Cosmos%20DB%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3EPartitioning%3C%2FSTRONG%3E%3A%20The%20first%20topic%20an%20IoT%20developer%20needs%20to%20understand%20is%20partitioning.%20Partitioning%20is%20how%20you%20will%20optimize%20for%20performance.%20Cosmos%20DB%20does%20the%20heavy%20lifting%20for%20you%20taking%20care%20of%20partition%20management%20and%20routing%20in%20particular.%20What%20you%20will%20need%20to%20do%20is%20choose%20a%20partition%20key%20that%20makes%20sense%20during%20design.%20The%20Partition%20key%20is%20what%20will%20determine%20how%20data%20is%20routed%20in%20the%20various%20DB%20partitions%20by%20Cosmos%20DB%20and%20needs%20to%20make%20sense%20in%20the%20context%20of%20your%20specific%20scenario.%20The%20Device%20Id%20is%20generally%20the%20%E2%80%9Cnatural%E2%80%9D%20partition%20key%20for%20IoT%20applications.%20Learn%20more%20on%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fcosmos-db%2Fpartition-data%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Epartitioning%3C%2FA%3E.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F157763iDE76919657FEFBBD%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22logical-partitions%22%20title%3D%22logical-partitions%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3ERequest%20Units%20(RUs)%3C%2FSTRONG%3E%3A%26nbsp%3BThe%20second%20topic%20an%20IoT%20developer%20needs%20to%20understand%20is%20Request%20Units.%20A%20Request%20Unit%20(RU)%20is%20the%20measure%20of%20throughput%20in%20Azure%20Cosmos%20DB.%20RUs%20are%20compute%20units%20for%20both%20performance%20and%20cost.%20With%20RUs%2C%20you%20can%20dynamically%20scale%20up%20and%20down%20while%20maintaining%20availability%2C%20optimizing%20for%20cost%2C%20performance%20and%20availability%20at%20the%20same%20time.%20RUs%20offer%20programmatic%20APIs%20for%20scenarios%20like%20batch%20jobs.%20Learn%20more%20about%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fcosmos-db%2Frequest-units%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ERequest%20Units%3C%2FA%3E.%26nbsp%3B%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F157762i048BBEF0A06037DD%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22request-units%22%20title%3D%22request-units%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3ETime%20to%20Live%3C%2FSTRONG%3E%3A%26nbsp%3BThe%20third%20topic%20IoT%20developers%20should%20understand%20is%20Time-to-Live%20or%20TTL.%20With%20TTL%2C%20Azure%20Cosmos%20DB%20provides%20the%20ability%20to%20delete%20items%20automatically%20from%20a%20container%20after%20a%20certain%20period%20of%20time.%20With%20the%20right%20understanding%20and%20use%20of%20TTL%20settings%20in%20Cosmos%20DB%2C%20and%20benefiting%20from%20the%20free%20deletes%2C%20you%20will%20save%2050%25%20compared%20to%20systems%20that%20charge%20IOPs%20for%20deletes.%20Learn%20more%20about%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fcosmos-db%2Ftime-to-live%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ETime%20to%20Live%3C%2FA%3E.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3EChange%20Feed%3C%2FSTRONG%3E%3A%26nbsp%3BThe%20final%20%E2%80%9Cneed%20to%20know%E2%80%9D%20topic%20is%20change%20feed.%20A%20common%20design%20pattern%20in%20IoT%20is%20to%20use%20changes%20to%20the%20data%20to%20trigger%20additional%20actions.%20Change%20feed%20support%20in%20Azure%20Cosmos%20DB%20works%20by%20listening%20to%20an%20Azure%20Cosmos%20container%20for%20any%20changes.%20It%20then%20outputs%20the%20sorted%20list%20of%20documents%20that%20were%20changed%20in%20the%20order%20in%20which%20they%20were%20modified.%20The%20change%20feed%20is%20a%20single%20source%20of%20truth.%20You%20will%20avoid%20consistency%20issues%20across%20multiple%20systems%20when%20using%20it%20correctly.%20Learn%20more%20about%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fcosmos-db%2Fchange-feed%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Echange%20feed%3C%2FA%3E.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F157764i81CC21BDD09CDADD%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22changefeedoverview%22%20title%3D%22changefeedoverview%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--73397444%22%20id%3D%22toc-hId--72622598%22%20id%3D%22toc-hId--72622598%22%20id%3D%22toc-hId--72622598%22%20id%3D%22toc-hId--72622598%22%20id%3D%22toc-hId--72622598%22%20id%3D%22toc-hId--72622598%22%20id%3D%22toc-hId--72622598%22%3ETry%20a%20hands-on%20lab%3C%2FH3%3E%0A%3CP%3ENot%20convinced%20yet%3F%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzureCosmosDB%2Fscenario-based-labs%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ETry%20a%20hands-on%20lab%3C%2FA%3E.%20In%20the%20lab%2C%20you%20will%20use%20Azure%20Cosmos%20DB%20to%20ingest%20streaming%20vehicle%20telemetry%20data%20as%20the%20entry%20point%20to%20a%20near%20real-time%20analytics%20pipeline%20built%20on%20Cosmos%20DB%2C%20Azure%20Functions%2C%20Event%20Hubs%2C%20Azure%20Databricks%2C%20Azure%20Storage%2C%20Azure%20Stream%20Analytics%2C%20Power%20BI%2C%20Azure%20Web%20Apps%2C%20and%20Logic%20Apps.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1015605%22%20slang%3D%22en-US%22%3E%3CP%20style%3D%22text-align%3A%20center%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20990px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F157774i88787FB7031B0B74%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%221097281592462201030_1097281592462201030.jpg%22%20title%3D%221097281592462201030_1097281592462201030.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3EWhy%20should%20you%20care%20about%20Azure%20Cosmos%20DB%20when%20developing%20an%20IoT%20solution%20in%20Azure%3F%20Here%20is%20an%20attempt%20at%20explaining%20what%20Cosmos%20DB%20is%20great%20for%20in%20IoT%20apps.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1015605%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%20IoT%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Ecosmos%20db%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EIoT%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EIoT%20Hub%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMicrosoft%20IoT%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1034093%22%20slang%3D%22en-US%22%3ERe%3A%20IoT%20Solutions%20and%20Azure%20Cosmos%20DB%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1034093%22%20slang%3D%22en-US%22%3E%3CP%3EGiven%20the%20volume%20of%20data%20and%20the%2010Gb%20partition%20limit%2C%20what%20is%20the%20approach%20for%20keeping%20data%20sizes%20in%20check%3F%20In%20your%20example%2C%20a%20city%20with%20multiple%20oil%20wells%20would%20probably%20hit%20that%20limit%20rather%20quickly%20(days%2Fweeks).%20Is%20the%20approach%20just%20to%20introduce%20look-back%20reporting%20constraints%20for%20hot%20data%20and%20leverage%20TTL%3F%20In%20very%20high%20volume%20IoT%20scenarios%20with%20business%20requirements%20around%20look-back%20this%20could%20be%20an%20issue.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1034254%22%20slang%3D%22en-US%22%3ERe%3A%20IoT%20Solutions%20and%20Azure%20Cosmos%20DB%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1034254%22%20slang%3D%22en-US%22%3E%3CP%3E%3CEM%3EGiven%20the%20volume%20of%20data%20and%20the%2010Gb%20partition%20limit%2C%20what%20is%20the%20approach%20for%20keeping%20data%20sizes%20in%20check%3F%20In%20your%20example%2C%20a%20city%20with%20multiple%20oil%20wells%20would%20probably%20hit%20that%20limit%20rather%20quickly%20(days%2Fweeks).%20Is%20the%20approach%20just%20to%20introduce%20look-back%20reporting%20constraints%20for%20hot%20data%20and%20leverage%20TTL%3F%20In%20very%20high%20volume%20IoT%20scenarios%20with%20business%20requirements%20around%20look-back%20this%20could%20be%20an%20issue.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou're%20absolutely%20correct%20that%20devices%20generally%20produce%20data%20at%20a%20fast%20rate%20-%20which%20is%20why%20Cosmos%20DB%20is%20usually%20used%20as%20a%20landing%20zone%20for%20ingest.%3C%2FP%3E%0A%3CP%3EIf%20you%20were%20to%20assume%20a%201%20KB%20record%20per%20device%20per%20second%20*%2060%20seconds%20per%20minute%20*%2060%20minutes%20per%20hour%20*%2024%20hours%20in%20a%20day%20%3D%26gt%3B%20a%20device%20will%20produce%20an%20estimated%20~2.5GB%20per%20Month.%20Generally%20speaking%20-%20people%20handle%20this%202%20different%20ways%20(which%20of%20course%2C%20aren't%20mutually%20exclusive)%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E1st%20method%20is%20to%20to%20set%20the%20partition%20key%20to%20an%20artificial%20field%20called%20%2FpartitionKey%20-%20and%20assign%20a%20composite%20value%20(e.g.%20Device%20ID%20%2B%20Current%20Month%20and%20Year).%20This%20enables%20the%20workload%20to%20write%20to%20a%20extremely%20high%20cardinality%20of%20values%20(1%20discrete%20value%20per%20device)%20and%20thus%20load%20balancing%20the%20throughput%20on%20the%20system's%20underlying%20partitions.%20At%20the%20same%20time%2C%20this%20preserves%20efficiency%20of%20common%20query%20patterns%20in%20hot%20telemetry%20data%20without%20having%20to%20blindly%20fan-out%20(e.g.%20SELECT%20*%20FROM%20c%20WHERE%20c.partitionKey%20IN%20(%22device123-Jan-2019%22%2C%26nbsp%3B%22device123-Feb-2019%22%2C%26nbsp%3B%22device123-March-2019%22).%20The%20rest%20of%20the%20queries%20can%20fan-out%20but%20that's%20okay%20-%20as%20the%20telemetry%20generally%20follows%20a%20pareto%20principal%20and%20is%20generally%20heavily%20skewed%20to%20being%20a%20write-heavy%20scenario%20with%20relatively%20low%20QPS%20(%26gt%3B80%25%20of%20operations%2Fsec%20are%20writes%2C%20not%20reads...%20optimize%20for%20the%2080%25%20instead%20of%20the%2020%25).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E2nd%20method%20is%20to%20tier%20data%20in%20to%20a%20hot-store%20(e.g.%20Cosmos%20DB)%20%2B%20cold-store%20(e.g.%20Blob%20Storage)%20by%20using%20a%20combination%20of%20TTL%20to%20automatically%20prune%20data%20from%20the%20hot%20store%20and%20change%20feed%20to%20replicate%20data%20from%20hot%20store%20%3D%26gt%3B%20cold%20store.%20Hot%20store%20enables%20low%20latency%20indexed%20queries%20over%20recent%20telemetry%3B%20meanwhile%20cold%20store%20enables%20low%20cost%20commodity%20storage%20for%20batch%20processing%20and%2For%20retaining%20data%20long%20term%20for%20regulatory%2Fcompliance%20reasons.%20The%20Cosmos%20DB%20team%20is%20actually%20working%20on%20operationalizing%20this%20pattern%20(since%20it%20comes%20up%20so%20often%20as%20a%20common%20scenario)%20in%20the%20form%20of%20its%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fcosmos-db%2Fglobally-distributed-transactional-analytical-storage%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eanalytical%20storage%3C%2FA%3E.%20This%20analytical%20storage%20feature%20is%20still%20in%20a%20gated%20preview%20(at%20the%20time%20of%20this%20post)%20-%20so%20I'd%20recommend%20using%20TTL%20%2B%20change%20feed%20for%20product%20use-cases%20until%20analytical%20storage%20feature%20graduates%20to%20GA.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1034323%22%20slang%3D%22en-US%22%3ERe%3A%20IoT%20Solutions%20and%20Azure%20Cosmos%20DB%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1034323%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20is%20by%20far%20the%20best%20reply%20to%20a%20comment%20on%20the%20Internet%20I've%20ever%20experienced.%20I'd%20suggest%20building%20on%20this%20and%20moving%20it%20in%20to%20an%20article%20or%20reference%20architecture%20for%20others%20to%20refer%20to%20as%20well.%20I'm%20sure%20I'm%20not%20the%20only%20one%20who%20saw%20that%2010GB%20limit%20and%20thought%20it%20looked%20like%20a%20deal%20breaker.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20still%20think%20the%20limit%20forces%20a%20look-back%20gap%20for%20real%20time%20reporting%20without%20beefing%20up%20RUs%20for%20fan%20out%20reads.%20Maybe%20the%20answer%20is%20more%20compute%20to%20roll%20up%20stats%20to%20report%20from%2C%20but%20it's%20not%20as%20clean%20as%20what%20I%20would%20hope%20for.%20That%20limit%20forces%20my%20collect%20and%20store%20strategy%20to%20be%20at%20odds%20with%20my%20read%20and%20report%20strategy.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20again%20for%20the%20deep%20dive%20in%20reply%20to%20my%20query.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1034325%22%20slang%3D%22en-US%22%3ERe%3A%20IoT%20Solutions%20and%20Azure%20Cosmos%20DB%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1034325%22%20slang%3D%22en-US%22%3E%3CP%3EThat's%20a%20great%20idea%20-%20will%20look%20in%20to%20this%20%3A)%3C%2Fimg%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1035394%22%20slang%3D%22en-US%22%3ERe%3A%20IoT%20Solutions%20and%20Azure%20Cosmos%20DB%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1035394%22%20slang%3D%22en-US%22%3E%3CP%3EVery%20interesting%20topic%20and%20it%20underlines%20the%20importance%20of%20thinking%20and%20working%20on%20good%20architectures.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20case%20it%20is%20useful%2C%20in%20the%20last%20IoT%20projects%2C%20we%20have%20been%20using%20a%20kind%20of%20mix%20of%20the%20two%20mentioned%20alternatives%3A%20method%202%20%2B%20%22rich%22%20partition%20keys.%20Besides%20performance%20(natural%20and%20straightforward%20requirement)%2C%20we%20did%20this%20to%20optimize%20costs.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EConceptually%20speaking%2C%20TTL%20is%20a%20very%20simple%20feature%20but%20extremely%20useful.%3C%2FP%3E%3C%2FLINGO-BODY%3E

Here are the 2 main reasons why Azure Cosmos DB is great for in IoT applications:

  • Cosmos DB can ingest semi-structured data at extremely high rates.
  • Cosmos DB can serve indexed queries back out with extremely low latency and high availability.

For a fascinating history and in-depth technical outline of Cosmos DB, check out this blog by Dharma Shukla Founder of Azure Cosmos DB, Technical Fellow, Microsoft.

The two primary IoT use cases for Cosmos DB are storing device telemetry and managing a device catalog. Read on to learn key details and catch this Channel 9 IoT Show episode with Andrew Liu, Program Manager, Cosmos DB team:

 

 

Storing device telemetry

The first IoT use case for Cosmos DB is storing telemetry data in a way that allows for rapid access to the data for visualization, post processing and analytics.

XTO Energy, a subsidiary of ExxonMobil, uses Cosmos DB for this exact scenario. The company has 50,000 oil wells generating telemetry data like flow rate and temperature at a high throughput. With lots and lots of bytes/second coming in, XTO DB uses Cosmos DB because of its fast, indexed data store, partitioning, and automatic indexing. See the architecture diagram below showing how Cosmos DB fits in their IoT solution. Note that data comes into Azure IoT Hub. Typically, you would position a hot store (with fast, interactive queries) and cold store behind IoT Hub. In this case, Azure Cosmos DB is used for the hot store. Read more about XTO Energy use of Azure Cosmos DB and Azure IoT.

 

CosmosDB picture1.png

 

Device catalog

A second IoT scenario that benefits using Cosmos DB is managing a device catalog for critical processes. This is where the low latency and "always on" guarantees of Cosmos DB comes in. Less than 10-ms latencies for both, reads (indexed) and writes at the 99th percentile, all around the world and 99.999% availability for multi-region writes!

Azure Cosmos DB transparently replicates your data across all the Azure regions associated with your Cosmos account. Cosmos DB employs multiple layers of redundancy for your data managing partitioning for you. Learn more about Cosmos DB high availability.

A real-life scenario example is that of an automobile manufacturer running an assembly line with high availability requirements. The manufacturer drives commands to robots that manufacture the cars. In order to ensure that the assembly line never stops, the manufacturer uses Cosmos DB to ensure extremely high availability and low latency.

 

Getting started with Cosmos DB for IoT

There are four “must-know” aspects that IoT developers need to understand to work with Cosmos DB:

  • Partitioning: The first topic an IoT developer needs to understand is partitioning. Partitioning is how you will optimize for performance. Cosmos DB does the heavy lifting for you taking care of partition management and routing in particular. What you will need to do is choose a partition key that makes sense during design. The Partition key is what will determine how data is routed in the various DB partitions by Cosmos DB and needs to make sense in the context of your specific scenario. The Device Id is generally the “natural” partition key for IoT applications. Learn more on partitioning.

logical-partitions

 

  • Request Units (RUs): The second topic an IoT developer needs to understand is Request Units. A Request Unit (RU) is the measure of throughput in Azure Cosmos DB. RUs are compute units for both performance and cost. With RUs, you can dynamically scale up and down while maintaining availability, optimizing for cost, performance and availability at the same time. RUs offer programmatic APIs for scenarios like batch jobs. Learn more about Request Units

request-units

 

  • Time to Live: The third topic IoT developers should understand is Time-to-Live or TTL. With TTL, Azure Cosmos DB provides the ability to delete items automatically from a container after a certain period of time. With the right understanding and use of TTL settings in Cosmos DB, and benefiting from the free deletes, you will save 50% compared to systems that charge IOPs for deletes. Learn more about Time to Live.

 

  • Change Feed: The final “need to know” topic is change feed. A common design pattern in IoT is to use changes to the data to trigger additional actions. Change feed support in Azure Cosmos DB works by listening to an Azure Cosmos container for any changes. It then outputs the sorted list of documents that were changed in the order in which they were modified. The change feed is a single source of truth. You will avoid consistency issues across multiple systems when using it correctly. Learn more about change feed.

changefeedoverview

 

Try a hands-on lab

Not convinced yet? Try a hands-on lab. In the lab, you will use Azure Cosmos DB to ingest streaming vehicle telemetry data as the entry point to a near real-time analytics pipeline built on Cosmos DB, Azure Functions, Event Hubs, Azure Databricks, Azure Storage, Azure Stream Analytics, Power BI, Azure Web Apps, and Logic Apps.

 

 

5 Comments
Frequent Visitor

Given the volume of data and the 10Gb partition limit, what is the approach for keeping data sizes in check? In your example, a city with multiple oil wells would probably hit that limit rather quickly (days/weeks). Is the approach just to introduce look-back reporting constraints for hot data and leverage TTL? In very high volume IoT scenarios with business requirements around look-back this could be an issue.

Microsoft

Given the volume of data and the 10Gb partition limit, what is the approach for keeping data sizes in check? In your example, a city with multiple oil wells would probably hit that limit rather quickly (days/weeks). Is the approach just to introduce look-back reporting constraints for hot data and leverage TTL? In very high volume IoT scenarios with business requirements around look-back this could be an issue.

 

You're absolutely correct that devices generally produce data at a fast rate - which is why Cosmos DB is usually used as a landing zone for ingest.

If you were to assume a 1 KB record per device per second * 60 seconds per minute * 60 minutes per hour * 24 hours in a day => a device will produce an estimated ~2.5GB per Month. Generally speaking - people handle this 2 different ways (which of course, aren't mutually exclusive):

 

1st method is to to set the partition key to an artificial field called /partitionKey - and assign a composite value (e.g. Device ID + Current Month and Year). This enables the workload to write to a extremely high cardinality of values (1 discrete value per device) and thus load balancing the throughput on the system's underlying partitions. At the same time, this preserves efficiency of common query patterns in hot telemetry data without having to blindly fan-out (e.g. SELECT * FROM c WHERE c.partitionKey IN ("device123-Jan-2019", "device123-Feb-2019", "device123-March-2019"). The rest of the queries can fan-out but that's okay - as the telemetry generally follows a pareto principal and is generally heavily skewed to being a write-heavy scenario with relatively low QPS (>80% of operations/sec are writes, not reads... optimize for the 80% instead of the 20%).

 

2nd method is to tier data in to a hot-store (e.g. Cosmos DB) + cold-store (e.g. Blob Storage) by using a combination of TTL to automatically prune data from the hot store and change feed to replicate data from hot store => cold store. Hot store enables low latency indexed queries over recent telemetry; meanwhile cold store enables low cost commodity storage for batch processing and/or retaining data long term for regulatory/compliance reasons. The Cosmos DB team is actually working on operationalizing this pattern (since it comes up so often as a common scenario) in the form of its analytical storage. This analytical storage feature is still in a gated preview (at the time of this post) - so I'd recommend using TTL + change feed for product use-cases until analytical storage feature graduates to GA.

Frequent Visitor

This is by far the best reply to a comment on the Internet I've ever experienced. I'd suggest building on this and moving it in to an article or reference architecture for others to refer to as well. I'm sure I'm not the only one who saw that 10GB limit and thought it looked like a deal breaker.

 

I still think the limit forces a look-back gap for real time reporting without beefing up RUs for fan out reads. Maybe the answer is more compute to roll up stats to report from, but it's not as clean as what I would hope for. That limit forces my collect and store strategy to be at odds with my read and report strategy.

 

Thanks again for the deep dive in reply to my query.

Microsoft

That's a great idea - will look in to this :)

Occasional Contributor

Very interesting topic and it underlines the importance of thinking and working on good architectures.

 

In case it is useful, in the last IoT projects, we have been using a kind of mix of the two mentioned alternatives: method 2 + "rich" partition keys. Besides performance (natural and straightforward requirement), we did this to optimize costs.

 

Conceptually speaking, TTL is a very simple feature but extremely useful.