Get more than a cache back! The Microsoft Azure (Redis) Cache Maarten

Slides:



Advertisements
Similar presentations
A Survey of Distributed Database Management Systems Brady Kyle CSC
Advertisements

Mark Simms Principal Program Manager Windows Azure Customer Advisory Team.
Azure Services Platform Piotr Zierhoffer. Agenda Cloud? What is Azure? Environment Basic glossary Architecture Element description Deployment.
PHP (2) – Functions, Arrays, Databases, and sessions.
Basic concept Technologies we have used The Design Problems, challenges & solutions Educational Gain.
Google Bigtable A Distributed Storage System for Structured Data Hadi Salimi, Distributed Systems Laboratory, School of Computer Engineering, Iran University.
Multiple Tiers in Action
& Silverlight, Windows Phone 7, Windows Azure, jQuery, OData and RIA Services. Shaken, not stirred. Kevin
Protecting your online and on premises assets "Cloud Style" Mike Martin Architect / Microsoft Azure MVP.
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
Mastering Redis A Primer Data Masters. Special Thanks To… Planet Linux Caffe
Platform as a Service (PaaS)
SQL Server Replication By Karthick P.K Technical Lead, Microsoft SQL Server.
Projects ( ) Ida Mele. Rules Students have to work in teams (max 2 people). The project has to be delivered by the deadline that will be published.
OAuth-as-a-service using ASP.NET Web API and Windows Azure Access Control Maarten
Selecting and Implementing An Embedded Database System Presented by Jeff Webb March 2005 Article written by Michael Olson IEEE Software, 2000.
Building, Running, and Managing Workflows on Windows Azure Jürgen Willis Group Program Manager Microsoft Corporation.
Real-time Web Application with Node.js CENTRE FOR NETWORK RESEARCH COMPUTER ENGINEERING, PRINCE OF SONGKLA UNIVERSITY 1 Aj. Suthon, Nong Gun, Nong Pop.
 Anil Nori Distinguished Engineer Microsoft Corporation.
Austin code camp 2010 asp.net apps with azure table storage PRESENTED BY CHANDER SHEKHAR DHALL
What’s New? – BCS 2013 Brett Lonsdale.  Co-founder of Lightning Tools  One of the hosts on the SharePoint Pod Show  Co-organizer of SharePoint Saturday.
HBase A column-centered database 1. Overview An Apache project Influenced by Google’s BigTable Built on Hadoop ▫A distributed file system ▫Supports Map-Reduce.
Computer Measurement Group, India Optimal Design Principles for better Performance of Next generation Systems Balachandar Gurusamy,
M1G Introduction to Database Development 6. Building Applications.
LiveCycle Data Services Introduction Part 2. Part 2? This is the second in our series on LiveCycle Data Services. If you missed our first presentation,
Meet with the AppEngine Márk Gergely eu.edge. What is AppEngine? It’s a tool, that lets you run your web applications on Google's infrastructure. –Google's.
TEMPDB Capacity Planning. Indexing Advantages – Increases performance – SQL server do not have to search all the rows. – Performance, Concurrency, Required.
Ideas to Improve SharePoint Usage 4. What are these 4 Ideas? 1. 7 Steps to check SharePoint Health 2. Avoid common Deployment Mistakes 3. Analyze SharePoint.
IMDGs An essential part of your architecture. About me
 70s - Database access is hard and depends on the app  80s – Relational databases come on the scene  90s – Object oriented programming and DBs  00s.
Redis Key-Value Database: Practical Introduction
CH1. Hardware: CPU: Ex: compute server (executes processor-intensive applications for clients), Other servers, such as file servers, do some computation.
Caching Chapter 12. Caching For high-performance apps Caching: storing frequently-used items in memory –Accessed more quickly Cached Web Form bypasses:
Hibernate Persistence. What is Persistence Persist data to database or other storage.  In OO world, persistence means persist object to external storage.
ASP.NET Caching - Pradeepa Chandramohan. What is Caching? Storing data in memory for quick access. In Web Application environment, data that is cached.
Server to Server Communication Redis as an enabler Orion Free
INTRODUCTION TO DBS Database: a collection of data describing the activities of one or more related organizations DBMS: software designed to assist in.
Building Mobile Phone Applications With Windows Azure Nick HarrisWindows Azure Technical Evangelist Microsoft Blog:
Building Connected Windows 8 Apps with Windows Azure Web Sites Name Title Organization.
Alwayson Availability Groups
Mobile + Cloud: Building Mobile Applications with Windows Azure Wade Wegner Blog:
Scalable Data Scale #2 site on the Internet (time on site) >200 billion monthly page views Over 1 million developers in 180 countries.
Technology Drill Down: Windows Azure Platform Eric Nelson | ISV Application Architect | Microsoft UK |
Building Cloud Solutions Presenter Name Position or role Microsoft Azure.
(re)-Architecting cloud applications on the windows Azure platform CLAEYS Kurt Technology Solution Professional Microsoft EMEA.
Mobile Services Recap Windows Azure Mobile Services.
Building web applications with the Windows Azure Platform Ido Flatow | Senior Architect | Sela | This session.
Inspirirani ljudima. Ugasite mobitele. Hvala.. Paolo Pialorsi Senior Consultant PiaSys ( Publishing apps for SharePoint 2013 on Microsoft.
SQL Server Deep Dive Denis Reznik Data Architect at Intapp.
The best of WF 4.0 and AppFabric Damir Dobric MVP-Connected System Developer Microsoft Connected System Division Advisor Visual Studio Inner Circle member.
 Cloud Computing technology basics Platform Evolution Advantages  Microsoft Windows Azure technology basics Windows Azure – A Lap around the platform.
Fundamentals of Web DevelopmentRandy Connolly and Ricardo HoarFundamentals of Web DevelopmentRandy Connolly and Ricardo Hoar Fundamentals of Web DevelopmentRandy.
Top 10 Entity Framework Features Every Developer Should Know
Platform as a Service (PaaS)
An introduction to Wait Statistics
Deploying Web Application
Platform as a Service (PaaS)
Redis:~ Author Anil Sharma Data Structure server.
SharePoint Solutions Architect, Protiviti
Open Source distributed document DB for an enterprise
CSE-291 Cloud Computing, Fall 2016 Kesden
MongoDB Distributed Write and Read
Did your feature got in, out or planned?
BTEC NCF Dip in Comp - Unit 15 Website Development Lesson 05 – Website Performance Mr C Johnston.
Microsoft Build /6/2018 4:55 PM © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY,
PaaS - Development Stefan Geiger Gerry
AlwaysOn Availability Groups
Developing and testing enterprise Java applications
5 Azure Services Every .NET Developer Needs to Know
Why should I care about SQL, if I have ORM?
Presentation transcript:

Get more than a cache back! The Microsoft Azure (Redis) Cache Maarten

Abstract Get more than a cache back! The Microsoft Azure (Redis) Cache The Microsoft Azure Redis Cache must be the fourth or fifth generation of a hosted cache service on Azure. This time, an open-source solution has been embraced: Redis. In this session, we’ll see that it’s more than just an in-memory cache system we can use in our applications. Let’s explore what Redis is, what the different data types are and why we should care. And once we grasp how Redis stores its stuff, we’ll delve into how we can use it to its fullest extent: searching the key-value store, transactions, pub/sub support and scripting.

Who am I? Maarten Balliauw Antwerp, Belgium Software Engineer, Microsoft Founder, MyGet AZUG Focus on web ASP.NET MVC, Azure, SignalR,... Former MVP Azure & ASPInsider Big passion: Azure Shameless self promotion: Pro NuGet -

Agenda Azure Cache Redis Data types Transactions Pub/sub Scripting Sharding/partitioning Patterns

Azure Cache

Caching on Azure Windows Server: AppFabric (“Velocity”) ( ) Azure (ASP.NET cache) “Shared Cache” (AppFabric cache, multi-tenant) Self-Hosted Dedicated Cache Managed Cache (the above, but managed by Microsoft and with an SLA) A bit of history...

Caching on Azure 1920: Cache used to be a cache 2012: Cache became the go-to datastore Twitter stores 800 tweets / timeline in Redis New application types on Azure: PHP, Node, Java,... Too much work to write AppFabric clients for all! Way easier: just make it work on Windows and Azure New ways to develop applications

Redis

“Redis is an open source, BSD licensed, networked, single-threaded, in-memory key-value cache and store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets, sorted sets, bitmaps and hyperloglogs. ”strings hasheslistssetssorted setsbitmapshyperloglogs

Redis Key-value cache and store (value can be a couple of things) In-memory (no persistence, but you can) Single-threaded (atomic operations & transactions) Networked (it’s a server and it does master/slave) Some other stuff (scripting, pub/sub, Sentinel, snapshot, …) Things to remember

So no persistence? Possible using a lot of I/O AOF (append-only files) RDB (Redis DB snapshots) With or without: all your data must fit in memory

Redis 101 demo

The Little Redis Book By Karl Seguin

Data types TypeExample KeyExample value Stringcache:/home Home page Hashcategories:1Field name description numproducts Member Books Books for sale Setcategories:1:products Listproducts:20:comments[0] -> “...” [1] -> “...” [2] -> “...” Sorted setproducts:bestsellersField Eye Patch Parrot Score Bitmap, Hyperloglog

Data types demo

Data types TypeExample KeyExample value Stringcache:/home user:nextid Home page 2 Hashuser:1Field name handle Member Setuser:1:followers Listuser:1:timeline[0] -> “...” [1] -> “...” [2] -> “...” Sorted settrending:se:tagsField #sdc #redis Score Bitmap, Hyperloglog

Keys Good practice: use a pattern for keys E.g. users:1:maarten Get by id: KEYS users:1:* GET Get by name: KEYS users:*:maarten GET O(N) operation – use with caution! (SCAN)

But....NET? Lots of options! NuGet: ServiceStack.Redis StackExchange.Redis RedisAspNetProviders

Connecting to Redis from.NET demo

But... Azure? “It’s just Redis!” Main differences: auth mechanism and SSL support Use local for development from GitHub or NuGet (Redis-32 or Redis-64)

Azure Redis Cache demo

Azure Redis Cache Redis + Auth + SSL Monitoring Alerts Awesome tool:

Transactions MULTI, EXEC, DISCARD, WATCH No rollbacks (just discard queue) Failures are because of you, not Redis Optimistic locking with WATCH Only execute transaction queue if watched keys did not change

Transactions demo

Pub/Sub (P)SUBSCRIBE, UNSUBSCRIBE, PUBLISH Subscribe to a queue SUBSCRIBE news (or PSUBSCRIBE news:*) Send data to a queue PUBLISH news “This just in!” (optional) Keyspace notifications CONFIG SET notify-keyspace-events KEA PSUBSCRIBE '__key*__:*' (or

Pub/Sub demo

Scripting Run Lua scripts on Redis EVAL ‘return “Hello, World!”’ 0 Scripts are cached (SCRIPT FLUSH) Scripts can be used as functions Although we must pass the body all the time (or use SCRIPT LOAD + EVALSHA) Helper functions available! Base, table, string, math, debug, struct, cjson, cmsgpack, redis.sha1hex

Scripting demo

What if I need more memory? Sharding! On client (consistent hashing) On server (Redis Cluster, not on Azure) Using a proxy (Twemproxy - var options = new ConfigurationOptions { EndPoints = { "my-server" }, Proxy = Proxy.Twemproxy };

Patterns

When can I use Redis? ASP.NET Output Caching (RedisAspNetProviders) ASP.NET Session State General-purpose cache Table Storage secondary index “Cache with benefits” Pub/sub Generally: when use case maps and data fits in RAM

When should I avoid Redis? More data than can fit in RAM Can use multiple, but even then: SUM(RAM) == max. data size Data and query model fits well in a relational model Materialize certain queries in Redis if needed Avoid Redis for large objects Especially with lots of concurrent read/write operations

Counting stuff How would you count “likes” if you were Facebook? Table Storage 1 entity per likeable entity + per server instance for writes, sum entities for read I/O and CPU time... SQL UPDATE... Locking... Redis INCR post:12345 (Every once in a while, check keys to persist)

Counting stuff (2) How would you count “likes” if you were Facebook? And how would you get the 5 most popular posts? Use a sorted set Elements are scored (= # of likes) We can use ZREVRANGE to get the top X posts ZREVRANGE posts:likes 0 5 withscores

Get the latest 5 product reviews No need to go to the database Use a Redis List, truncated at 5 items Need more? Query the database

Rate limiting API should only allows 5 requests per 60 seconds Redis List Record 5 latest requests If we’re at 5, check the leftmost item versus current time :20:2512:20:2212:20:2112:20:1812:19:50

What’sUp? Sending short messages between parties, how to implement? Pub/Sub: Every user gets a subscription, others can end to that subscription Server listens on all subscriptions to archive/persist messages When user comes online, server can publish messages since last visit from archive/a Redis list

Autocompletion How to provide autocompletion over our million- records product catalog? SQL “LIKE” Lucene.NET / ElasticSearch Redis Sorted Set

Intersecting collections “Which friends do we have in common?” Algorithm could be: Find friends that we have in common Find friends they have in common Score the # of connections

Sort We have a series of bugs Priority, Status, Title,... A user follows a few of these bugs How to store? How to query? (give me my top 5 bugs by priority)

Conclusion

Azure Cache Redis is not just a cache Data types Transactions Pub/sub Scripting Sharding/partitioning Patterns 1 thing to remember:

Thank you!