Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Redis tutoring


Published on

Redis Introduction and customized framework base on StackExchange.Redis but update to using singleton pattern and JSON
Configuration Mapping with Redis Instance Group and Name concept.

Published in: Engineering
  • ⇒ ⇐ This service will write as best as they can. So you do not need to waste the time on rewritings.
    Are you sure you want to  Yes  No
    Your message goes here
  • I'd advise you to use this service: ⇒ ⇐ The price of your order will depend on the deadline and type of paper (e.g. bachelor, undergraduate etc). The more time you have before the deadline - the less price of the order you will have. Thus, this service offers high-quality essays at the optimal price.
    Are you sure you want to  Yes  No
    Your message goes here
  • Brent Forsman is paralyzed from a hunting accident. He now uses the Demolisher system to generate income. He says: "I believe there is no way this system can fail!" ●●●
    Are you sure you want to  Yes  No
    Your message goes here

Redis tutoring

  1. 1. Redis Tutoring Blackie 2015/10/12
  2. 2. Redis Introduction StackExchange.Redis Introduction RedisDemo Introduction Tools
  3. 3. Who am I Blackie Tsai Senior IT consultant of Xuenn Full stack developer Major on development of real-time transaction system with low latency and high concurrent Learning CI&CD and run with Agile&LEAN Blog
  5. 5. Redis Redis - A.K.A Remote Directory Server. It is an open source (BSD licensed), one of Key-Value database of NoSQL, in-memory data structure store, used as database, cache and message broker. It also can run atomic operations. Most Popular NoSQL( Recommend using Linux for deploying. Features Pure Simple Single Tread In-memory but persistent on disk database Remote dictionary server 3.0.4 is the latest stable version. 開源資料庫Redis實戰經驗大公開
  6. 6.
  7. 7. Over 70% would like to run a database or other stateful service in their container environments, with MySQL and Redis the two leading choices Important features for data management in container solutions were: Integration of data management capabilities into existing container work flow and tools seamless movement of data between dev, test and production environments.
  8. 8. Who using Redis Facebook’s Instagram: Making the Switch to Cassandra from Redis, a 75% ‘Insta’ Savings、
  9. 9.
  10. 10. Redis - Data Persistence Master Redis Slaver Redis Persistence to Disk Server A Server B Replication IMPLEMENTING PERSISTENCE IN REDIS • Master instance with no persistence • Slave instance with AOF enabled
  11. 11. Redis - PubSub SignalR Scaleout with Redis
  12. 12. Redis - Insight Of Pit Server-side session with Redis Redis has many eviction policies, but most of them are based on 'sampling‘. Alternative Solution Use Database as an another back-end Use Redis 3.0 Maximize CPUs usage Redis is single thread. One instance usually only use one CPU Redis, another step on the road
  13. 13. Redis - DataStore
  14. 14. Redis – LUA Script Redis embedded scripting language Good Learning : Lua: 给 Redis 用户的入门指导 5 Methods For Tracing and Debugging Redis Lua Scripts
  16. 16. Stack Exchange The world’s largest programming community is growing Stack Exchange is a network of 130+ Q&A communities including Stack Overflow Global traffic ranking 54th largest website
  17. 17. Architecture of Stack Exchange
  18. 18. Stack Exchange - Info Stack Overflow still uses Microsoft products. Stack Overflow still uses a scale-up strategy with HA. SQL Servers loaded with 384 GB of RAM and 2TB of SSD. Stats 4 million users, 8 million questions, 40 million answers, 560 million pageviews a month. Peak is more like 2600-3000 requests/sec on most weekdays. 25 servers, Stack Overflow has a 40:60 read-write ratio. 2 TB of SQL data all stored on SSDs, Each web server has 2x 320GB SSDs in a RAID 1. DB servers average 10% CPU utilization, 11 web servers, using IIS. 2 load balancers, 1 active, using HAProxy 4 active database nodes, using MS SQL 2 machines for distributed cache and messaging using Redis 2 read-only SQL Servers for used mainly for the Stack Exchange API 3 machines doing search with ElasticSearch
  19. 19. Stack Exchange - Caching Caching Cache all the things. 5 levels of caches. 1st: Caching in the browser, CDN, and proxies. 2nd: Using HttpRuntime.Cache. An in- memory, per server cache. 3rd: Redis. 4th: SQL Server Cache. 5th: SSD.
  20. 20. Stack Exchange - Lessons Learned Why use Redis if you use MS products? gabeech: It's not about OS evangelism. We run things on the platform they run best on. Period. C# runs best on a windows machine, we use IIS. Redis runs best on a *nix machine we use *nix. Overkill as a strategy SSDs Rock Know your read/write workload Keeping things very efficient means new machines are not needed often Don’t be afraid to specialize Do only what needs to be done Reinvention is OK Go down to the bare metal No bureaucracy. Garbage collection driven programming The cost of inefficient code can be higher than you think
  21. 21. StackExchange.Redis Basic Usage - getting started and basic usage Configuration - options available when connecting to redis Pipelines and Multiplexers - what is a multiplexer? Keys, Values and Channels - discusses the data-types used on the API Transactions - how atomic transactions work in redis Events - the events available for logging / information purposes Pub/Sub Message Order - advice on sequential and concurrent processing Scripting - running Lua scripts with convenient named parameter replacement
  22. 22. How to use
  23. 23. Configuration Automatic and Manual Configuration String Parse Constructor New Constructor Configuration Options Renaming Commands Twemproxy StackExchange.Redis Configuration
  25. 25. RedisDemo Features Connection Mapping with Configuration Configuration with Redis Instance Group and Name concept supported Singleton pattern avoid resource waste Dependency StackExchange.Redis FX.Configuration Newtonsoft.Json Log4Net(Optional) Demo Version
  26. 26. RedisDemo - Configuration ConnectionSetting follow StackExchange.Redis ConfigurationOptions.Parse()
  27. 27. RedisDemo Framework - Example
  28. 28. Example Lab Example – Basic Strings Lists Sets Hashes Sorted Sets Example – Advance Sort Expire HashSet, HashGetAll and HashDelete Pub/Sub Pipelines Batch Example – Scripting
  29. 29. TOOLS
  30. 30. Redis Data Management Cross-platform redis desktop manager - desktop management GUI for mac OS X, Windows, Debian and Ubuntu.
  31. 31. Opserver Monitoring Tool of Stack Exchange Servers SQL clusters/instances Redis Elastic search Exception logs Haproxy
  32. 32. Redis Server with Docker Enable Virtualization Technology on Bios and install Docker Toolbox Create a Docker container for Redis Run the service Create your web application container If any problem you can remove and setup again docker-machine rm default docker-machine --native-ssh create -d virtualbox default Dockerizing a Redis service
  33. 33. Reference Scaling Stack Overflow (QCon NYC 2015) Redis, another step on the road Types of NoSQL databases StackOverflow Update: 560M Pageviews A Month, 25 Servers, And It's All About Performance Redis 设计与实现 《Redis 设计与实现》图片集