SlideShare une entreprise Scribd logo
1  sur  57
AngularJS + Asp.Net Web Api,
Signalr, EF6 + Redis:前後端
整合篇
開發技巧實戰系列(5/6) - Web 前後端整合
講師: 郭二文 (erhwenkuo@gmail.com)
Document, Source code & Training
Video (5/6)
• https://github.com/erhwenkuo/PracticalCoding
Previous Training Session Document,
Source code & Training Video (4/6)
• https://www.youtube.com/watch?v=
AjEG65JTKKU
• http://www.slideshare.net/erhwenku
o/04-integrate-entityframework
Agenda
• StackOverflow Architecture
• Redis Overview
• Developing Asp.Net C# with Redis
• Highchart , AngularJS ,Web API2 , SignalR2 , EF6 + Redis Integration
stackoverflow Architecture
“stackoverflow.com” Introduction
• Stack Overflow is a question and answer web site for professional
and enthusiast programmers
• It's 100% free, no registration required
• Rank#60 World-wide most popular web-site
Some Number of stackoverflow
• Ranked 54th for web-site traffic in the world
• 4 million users
• 40 million answers
• 560 million pageviews a month
• But…. Only 25servers used
Architecture of stackoverflow
• 2 load balancers, 1 active, using
HAProxy
• HAProxy is a free, very fast and
reliable solution offering high
availability, load balancing, and
proxying for TCP and HTTP-based
applications.
• HAProxy is Open Source
Architecture of stackoverflow
• 9 web servers, using Microsoft
IIS
Architecture of stackoverflow
• 2 machines for distributed cache
and messaging using Redis
Architecture of stackoverflow
• 3 machines doing search with
ElasticSearch
Architecture of stackoverflow
• 4 active database nodes, using
MS SQL
Architecture of stackoverflow
• 3 application servers
implementing the tag engine,
anything searching by tag hits
Architecture of stackoverflow
• The UI has message inbox that is sent
a message when you get a new
badge, receive a message, significant
event, etc. Done using WebSockets
(SignalR) and is powered by redis
(SignalR Redis Messaging Backplane )
Software Stack & Result
• Marco Cecconi - "The Architecture of StackOverflow“
• Youtube: https://www.youtube.com/watch?v=t6kM2EM6so4
• Details Info: http://highscalability.com/blog/2014/7/21/stackoverflow-update-560m-
pageviews-a-month-25-servers-and-i.html
Caching Strategy @ stackoverflow
• Cache all the things
• 5 levels of caches
• 1st: is the network level cache: caching in the browser, CDN, and proxies
• 2nd: given for free by the .Net framework and is called the HttpRuntime.Cache. An in-
memory, per server cache
• 3rd: Redis. Distributed in-memory key-value store. Share cache elements across different
servers that serve the same site. If StackOverflow has 9 servers then all servers will be
able to find the same cached items.
• 4th: SQL Server Cache. The entire database is cached in-memory
• 5th: SSD. Usually only hit when the SQL server cache is warming up
Redis Overview
Redis Website
Http://redis.io/
What’s Redis
• Redis is an open source, BSD licensed, advanced key-value
cache and store.
• It is often referred to as a data structure server, since keys
can contain:
• String
• Hash
• List
• Set
• Sorted Set
• Bitmap
• Hyperloglog
Installing Redis
• Suggest runing Redis on Linux for PRD environment
• Run Redis on Windows for DEV environment or Testing
purpose
Download Redis
Download Redis
• Get the latest Win64 release from Microsoft Github
• https://github.com/MSOpenTech/redis/tree/2.8/bin/release
• Download “redis-2.8.17.zip” and extract to specific folder
Run Redis Server
• Used text editor to modify “redis.windows.conf”
• Comment out “maxheap” and set the value to “1073741824(1GB)”
• Open a Windows command console & type in:
• “redis-server redis.windows.conf”
1
2
3
Using Redis Command Console Client
• Open a Windows command console & type in:
• “redis-cli”
1
2
Redis Commands: Get & Set
• Redis is a key-value store. By issuing the command “SET {key} {value}” you set the
value of {value} to {key}.
Redis Commands: Expire & Ttl
• You can set keys to expire in a given amount of time by using the command,
EXPIRE.
• EXPIRE {key} {total_live_in_seconds}
• TTL reports the time remaining before the key expires.
• TTL {key}
Redis Data Structure: List
• One of the distinguishing features of Redis is that the values of a key can be data-
structures, rather than just values
• Following commands pertain to List:
• RPUSH, LPUSH, LLEN, LRANGE, LTRIM, LINDEX, LSET, LREM, LPOP, RPOP, BLPOP,
BRPOP, RPOPLPUSH & SORT
Redis Data Structure: Set
• Set are similar to lists, except each element can occur only once.
• Following commands pertain to Set:
• SADD, SREM, SPOP, SMOVE, SCARD, SISMEMBER, SINTER, SINTERSTORE, SUNION,
SUNIONSTORE, SDIFF, SDIFFSTORE, SMEMBERS, SRANDMEMBER
Redis Data Structure: Hash
• Using a Hash, you can assign values to fields in each key.
• Following commands pertain to Hash:
• HSET, HGET, HSETNX, HMSET, HMGET, HINCRBY, HEXISTS, HDEL, HLEN, HKEYS, HVALS,
HGETALL
Redis Commands
• Redis All Commands: http://redis.io/commands
Different data
structures that Redis
support
Redis command for
specific data structure
Developing Asp.Net C#
with Redis
Environment Setup – Redis C# Client
1. Use NuGet to search “StackExchange.Redis” (C#
redis client)
2. Click “Install”
Environment Setup – Redis Desktop
Manger
1. Download “Redis Desktop Manager”
• https://github.com/uglide/RedisDesktopManager/rele
ases/download/0.7.6/redis-desktop-manager-
0.7.6.15.exe
2. Click “Install”
Redis in Practice#1 – WebApi Call
Counts by Day
• Potential for massive amounts of simple writes / reads
• Valuable data, but not mission critical
• Lots of row contention in SQL
Redis in Practice#1 – WebApi Call
Counts by Day
• What: Records Web API POST/PUT/GET/DELETE events
• {Url: “/api/Employees” , Method: “post” }
• When: Records When Web API events occurred
• {EventDate: 2014/12/22 10:00:00}
• Where: Records Which Web API Provider
• {Host: “server01”}
Redis in Practice#1 – WebApi Call
Counts by Day
webapi_call_count_by_day:yyyy-mm-dd:server01 employees:post 1024
Redis: Hash data structure:
{MetricName}:{When}:{Where} {What}
Something we
want to know
(Counter)
Key HashValueHashKey
Redis in Practice#1 – WebApi Call
Counts by Day
1. Create a new C# class “RedisConnHelper.cs” to get redis
connection object
2. Create a new C# POCO class “Employee.cs” as domain model
entity
3. Modify “EF6DbContext.cs” include EF6 ORM support for
“Employee.cs”
4. Execute “Add-Migration AddEmployee” and “Update-
Database” in “Package Manager Console”
5. Add new web api controller named
“EmployeesControllers.cs”
Redis in Practice#1 – WebApi Call
Counts by Day (EmployeesController)
Redis in Practice#1 – WebApi Call
Counts by Day
1. Hit “F5” to run “PracticalCoding.Web”
2. Use “Fiddler2” to test below Web APIs (“/api/Employees”)
3. Use “Redis Desktop Manger” to see the Metric result
Demo
Redis in Practice#2 – Realtime
Metrics
• Traditionally, metrics are performed by a batch job (running hourly,
daily, etc.)
• Redis backed bitmaps allow us to perform such calculations in
realtime and are extremely space efficient.
Crash Course on Bitmap and Redis
Bitmaps
• Bitmap (aka Bitset)
• A Bitmap or bitset is an array of zeros and ones.
• A bit in a bitset can be set to either 0 or 1
• Eeach position in the array is referred to as an offset
• Redis support Bit Operations such as logical AND, OR, XOR & NOT
• Bitmaps in Redis
• Redis allows binary keys and binary values
• The setbit(key, offset, value) operation, which takes O(1) time, sets the
value of a bit to 0 or 1 at the specified offset for a given key.
The setbit(key, offset, value) operation, which takes O(1) time, sets the value of a bit to 0 or 1 at the specified offset for a given key.
Population Count
• The population count of a Bitmap is the total number of bits set to 1.
The setbit(key, offset, value) operation, which takes O(1) time, sets the value of a bit to 0 or 1 at the specified offset for a given key.
A Simple Example: Daily Active Users
• Purpose: To count unique users that logged in today
• HowTo:
• We set up a bitmap where each user is identified by an offset value
• When a user visits a page or performs an action, which warrants it to be
counted, set the bit to 1 at the offset representing user id
• The key for the bitmap is a function of the name of the action user performed
and the timestamp
• Every time a user logs in we perform:
• redis.setbit(daily_active_users, user_id, 1)
The setbit(key, offset, value) operation, which takes O(1) time, sets the value of a bit to 0 or 1 at the specified offset for a given key.
A Simple Example: Daily Active Users
(Session_05_UnitTest.Bitmap_Test.cs)
The setbit(key, offset, value) operation, which takes O(1) time, sets the value of a bit to 0 or 1 at the specified offset for a given key.
A Simple Example: Daily Active Users
(Session_05_UnitTest.Bitmap_Test.cs)
The setbit(key, offset, value) operation, which takes O(1) time, sets the value of a bit to 0 or 1 at the specified offset for a given key.
Demo
In my laptop, it can reach
around 400K op/s through put!!
The BitCount is very space
efficient and also the speed is fast!!
A Simple Example: Daily Active Users
(Session_05_UnitTest.Bitmap_Test.cs)
The setbit(key, offset, value) operation, which takes O(1) time, sets the value of a bit to 0 or 1 at the specified offset for a given key.
Demo
In my laptop, it can reach
around 400Kop/s through put!!
The BitCount is very space
efficient and also the speed is fast!!
Redis in Practice#3 – Redis as
Datastore
• “Memory is the new disk, disk is the new tape” – Jim Gray
• Twitter Uses Redis To Scale - 105TB RAM, 39MM QPS, 10,000+
Instances
• http://highscalability.com/blog/2014/9/8/how-twitter-uses-redis-to-scale-
105tb-ram-39mm-qps-10000-ins.html
Environment Setup
1. Use NuGet to search “NServiceKit.Redis”
2. Click “Install”
A Simple Example: Daily Active Users
(Session_05_UnitTest. Datastore_Test.cs)
The setbit(key, offset, value) operation, which takes O(1) time, sets the value of a bit to 0 or 1 at the specified offset for a given key.
Demo
Highchart , AngularJS
,Web API2 , SignalR2 ,
EF6 + Redis Integration
Integration with Entity Framework
• Copy “09_IntegrationWithEF6” to
“10_IntegrationWithRedis ”
Create New
RedisDashboardRepo.cs
Initial Chartdatas (Global.asax.cs)
Switch “EF6DashboardRepo” to
“RedisDashboardRepo”
• Copy “EF6DashboardController.cs” to “RedisDashboardController.cs”
Switch our Repository
from “EF6” to “redis”
Dispose
“RedisClient”
connection object to
release redis client
connection
Modify Our Angular “ChartDataFactory”
• Switch angular $http communication end point to our new WebAPI url
Before After
Integration with Redis
1. Select “10_Integration/index.html” and Hit “F5” to run
2. Open Multi-Browers to see charts reflect changes whenever C/U/D
operations occurred
Demo
Next Session:
AngularJS , Highchart , Asp.Net
WebApi2 , SignalR2 , EF6 , Redis +
Elasticsearch

Contenu connexe

Tendances

Dropwizard Internals
Dropwizard InternalsDropwizard Internals
Dropwizard Internalscarlo-rtr
 
An Overview of Node.js
An Overview of Node.jsAn Overview of Node.js
An Overview of Node.jsAyush Mishra
 
Apache spark with akka couchbase code by bhawani
Apache spark with akka couchbase code by bhawaniApache spark with akka couchbase code by bhawani
Apache spark with akka couchbase code by bhawaniBhawani N Prasad
 
Spring Batch Performance Tuning
Spring Batch Performance TuningSpring Batch Performance Tuning
Spring Batch Performance TuningGunnar Hillert
 
ELK Ruminating on Logs (Zendcon 2016)
ELK Ruminating on Logs (Zendcon 2016)ELK Ruminating on Logs (Zendcon 2016)
ELK Ruminating on Logs (Zendcon 2016)Mathew Beane
 
Tips and Tricks For Faster Asp.NET and MVC Applications
Tips and Tricks For Faster Asp.NET and MVC ApplicationsTips and Tricks For Faster Asp.NET and MVC Applications
Tips and Tricks For Faster Asp.NET and MVC ApplicationsSarvesh Kushwaha
 
Ajug - The Spring Update
Ajug - The Spring UpdateAjug - The Spring Update
Ajug - The Spring UpdateGunnar Hillert
 
Spring Projects Infrastructure
Spring Projects InfrastructureSpring Projects Infrastructure
Spring Projects InfrastructureGunnar Hillert
 
The Ultimate Logging Architecture - You KNOW you want it!
The Ultimate Logging Architecture - You KNOW you want it!The Ultimate Logging Architecture - You KNOW you want it!
The Ultimate Logging Architecture - You KNOW you want it!Michele Leroux Bustamante
 
Dropwizard and Groovy
Dropwizard and GroovyDropwizard and Groovy
Dropwizard and Groovytomaslin
 
FlutterでGraphQLを扱う
FlutterでGraphQLを扱うFlutterでGraphQLを扱う
FlutterでGraphQLを扱うIgaHironobu
 
Test driving Azure Search and DocumentDB
Test driving Azure Search and DocumentDBTest driving Azure Search and DocumentDB
Test driving Azure Search and DocumentDBAndrew Siemer
 
Riak Intro at Munich Node.js
Riak Intro at Munich Node.jsRiak Intro at Munich Node.js
Riak Intro at Munich Node.jsPhilipp Fehre
 
Oozie @ Riot Games
Oozie @ Riot GamesOozie @ Riot Games
Oozie @ Riot GamesMatt Goeke
 
サーバーサイドから見るGraphQL Serverless Meetup #19
サーバーサイドから見るGraphQL Serverless Meetup #19サーバーサイドから見るGraphQL Serverless Meetup #19
サーバーサイドから見るGraphQL Serverless Meetup #19Yutaka Tachibana
 

Tendances (20)

Dropwizard Internals
Dropwizard InternalsDropwizard Internals
Dropwizard Internals
 
Gradle - Build System
Gradle - Build SystemGradle - Build System
Gradle - Build System
 
Coscup
CoscupCoscup
Coscup
 
An Overview of Node.js
An Overview of Node.jsAn Overview of Node.js
An Overview of Node.js
 
Apache spark with akka couchbase code by bhawani
Apache spark with akka couchbase code by bhawaniApache spark with akka couchbase code by bhawani
Apache spark with akka couchbase code by bhawani
 
DrupalCon 2011 Highlight
DrupalCon 2011 HighlightDrupalCon 2011 Highlight
DrupalCon 2011 Highlight
 
Spring Batch Performance Tuning
Spring Batch Performance TuningSpring Batch Performance Tuning
Spring Batch Performance Tuning
 
ELK Ruminating on Logs (Zendcon 2016)
ELK Ruminating on Logs (Zendcon 2016)ELK Ruminating on Logs (Zendcon 2016)
ELK Ruminating on Logs (Zendcon 2016)
 
Tips and Tricks For Faster Asp.NET and MVC Applications
Tips and Tricks For Faster Asp.NET and MVC ApplicationsTips and Tricks For Faster Asp.NET and MVC Applications
Tips and Tricks For Faster Asp.NET and MVC Applications
 
Ajug - The Spring Update
Ajug - The Spring UpdateAjug - The Spring Update
Ajug - The Spring Update
 
Spring Projects Infrastructure
Spring Projects InfrastructureSpring Projects Infrastructure
Spring Projects Infrastructure
 
The Ultimate Logging Architecture - You KNOW you want it!
The Ultimate Logging Architecture - You KNOW you want it!The Ultimate Logging Architecture - You KNOW you want it!
The Ultimate Logging Architecture - You KNOW you want it!
 
Dropwizard and Groovy
Dropwizard and GroovyDropwizard and Groovy
Dropwizard and Groovy
 
FlutterでGraphQLを扱う
FlutterでGraphQLを扱うFlutterでGraphQLを扱う
FlutterでGraphQLを扱う
 
Test driving Azure Search and DocumentDB
Test driving Azure Search and DocumentDBTest driving Azure Search and DocumentDB
Test driving Azure Search and DocumentDB
 
The Spring Update
The Spring UpdateThe Spring Update
The Spring Update
 
Riak Intro at Munich Node.js
Riak Intro at Munich Node.jsRiak Intro at Munich Node.js
Riak Intro at Munich Node.js
 
Hazelcast
HazelcastHazelcast
Hazelcast
 
Oozie @ Riot Games
Oozie @ Riot GamesOozie @ Riot Games
Oozie @ Riot Games
 
サーバーサイドから見るGraphQL Serverless Meetup #19
サーバーサイドから見るGraphQL Serverless Meetup #19サーバーサイドから見るGraphQL Serverless Meetup #19
サーバーサイドから見るGraphQL Serverless Meetup #19
 

En vedette

Spark手把手:[e2-spk-s02]
Spark手把手:[e2-spk-s02]Spark手把手:[e2-spk-s02]
Spark手把手:[e2-spk-s02]Erhwen Kuo
 
Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...
Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...
Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...Theo Jungeblut
 
Building an Online-Recommendation Engine with MongoDB
Building an Online-Recommendation Engine with MongoDBBuilding an Online-Recommendation Engine with MongoDB
Building an Online-Recommendation Engine with MongoDBMongoDB
 
Introduction to rest.li
Introduction to rest.liIntroduction to rest.li
Introduction to rest.liJoe Betz
 
Clean Code Part I - Design Patterns at SoCal Code Camp
Clean Code Part I - Design Patterns at SoCal Code CampClean Code Part I - Design Patterns at SoCal Code Camp
Clean Code Part I - Design Patterns at SoCal Code CampTheo Jungeblut
 
Accidentally Manager – A Survival Guide for First-Time Engineering Managers
Accidentally Manager – A Survival Guide for First-Time Engineering ManagersAccidentally Manager – A Survival Guide for First-Time Engineering Managers
Accidentally Manager – A Survival Guide for First-Time Engineering ManagersTheo Jungeblut
 
Spark手把手:[e2-spk-s03]
Spark手把手:[e2-spk-s03]Spark手把手:[e2-spk-s03]
Spark手把手:[e2-spk-s03]Erhwen Kuo
 
Spark手把手:[e2-spk-s01]
Spark手把手:[e2-spk-s01]Spark手把手:[e2-spk-s01]
Spark手把手:[e2-spk-s01]Erhwen Kuo
 
Spark手把手:[e2-spk-s04]
Spark手把手:[e2-spk-s04]Spark手把手:[e2-spk-s04]
Spark手把手:[e2-spk-s04]二文 郭
 
Squire: A polyglot application combining Neo4j, MongoDB, Ruby and Scala @ FOS...
Squire: A polyglot application combining Neo4j, MongoDB, Ruby and Scala @ FOS...Squire: A polyglot application combining Neo4j, MongoDB, Ruby and Scala @ FOS...
Squire: A polyglot application combining Neo4j, MongoDB, Ruby and Scala @ FOS...Alberto Perdomo
 
手把手帶你學Docker 03042017
手把手帶你學Docker 03042017手把手帶你學Docker 03042017
手把手帶你學Docker 03042017Paul Chao
 
Spark徹底入門 #cwt2015
Spark徹底入門 #cwt2015Spark徹底入門 #cwt2015
Spark徹底入門 #cwt2015Cloudera Japan
 
Apache Spark超入門 (Hadoop / Spark Conference Japan 2016 講演資料)
Apache Spark超入門 (Hadoop / Spark Conference Japan 2016 講演資料)Apache Spark超入門 (Hadoop / Spark Conference Japan 2016 講演資料)
Apache Spark超入門 (Hadoop / Spark Conference Japan 2016 講演資料)NTT DATA OSS Professional Services
 
Big-data analytics: challenges and opportunities
Big-data analytics: challenges and opportunitiesBig-data analytics: challenges and opportunities
Big-data analytics: challenges and opportunities台灣資料科學年會
 
AngularJS Security: defend your Single Page Application
AngularJS Security: defend your Single Page Application AngularJS Security: defend your Single Page Application
AngularJS Security: defend your Single Page Application Carlo Bonamico
 
[DSC 2016] 系列活動:李宏毅 / 一天搞懂深度學習
[DSC 2016] 系列活動:李宏毅 / 一天搞懂深度學習[DSC 2016] 系列活動:李宏毅 / 一天搞懂深度學習
[DSC 2016] 系列活動:李宏毅 / 一天搞懂深度學習台灣資料科學年會
 
[系列活動] 手把手的深度學習實務
[系列活動] 手把手的深度學習實務[系列活動] 手把手的深度學習實務
[系列活動] 手把手的深度學習實務台灣資料科學年會
 
Powerpoint on environmental issues
Powerpoint on environmental issuesPowerpoint on environmental issues
Powerpoint on environmental issuesMonika Uppal
 

En vedette (19)

Spark手把手:[e2-spk-s02]
Spark手把手:[e2-spk-s02]Spark手把手:[e2-spk-s02]
Spark手把手:[e2-spk-s02]
 
Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...
Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...
Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...
 
Building an Online-Recommendation Engine with MongoDB
Building an Online-Recommendation Engine with MongoDBBuilding an Online-Recommendation Engine with MongoDB
Building an Online-Recommendation Engine with MongoDB
 
Introduction to rest.li
Introduction to rest.liIntroduction to rest.li
Introduction to rest.li
 
Clean Code Part I - Design Patterns at SoCal Code Camp
Clean Code Part I - Design Patterns at SoCal Code CampClean Code Part I - Design Patterns at SoCal Code Camp
Clean Code Part I - Design Patterns at SoCal Code Camp
 
Accidentally Manager – A Survival Guide for First-Time Engineering Managers
Accidentally Manager – A Survival Guide for First-Time Engineering ManagersAccidentally Manager – A Survival Guide for First-Time Engineering Managers
Accidentally Manager – A Survival Guide for First-Time Engineering Managers
 
Spark手把手:[e2-spk-s03]
Spark手把手:[e2-spk-s03]Spark手把手:[e2-spk-s03]
Spark手把手:[e2-spk-s03]
 
Spark手把手:[e2-spk-s01]
Spark手把手:[e2-spk-s01]Spark手把手:[e2-spk-s01]
Spark手把手:[e2-spk-s01]
 
Spark手把手:[e2-spk-s04]
Spark手把手:[e2-spk-s04]Spark手把手:[e2-spk-s04]
Spark手把手:[e2-spk-s04]
 
Squire: A polyglot application combining Neo4j, MongoDB, Ruby and Scala @ FOS...
Squire: A polyglot application combining Neo4j, MongoDB, Ruby and Scala @ FOS...Squire: A polyglot application combining Neo4j, MongoDB, Ruby and Scala @ FOS...
Squire: A polyglot application combining Neo4j, MongoDB, Ruby and Scala @ FOS...
 
手把手帶你學Docker 03042017
手把手帶你學Docker 03042017手把手帶你學Docker 03042017
手把手帶你學Docker 03042017
 
Spark徹底入門 #cwt2015
Spark徹底入門 #cwt2015Spark徹底入門 #cwt2015
Spark徹底入門 #cwt2015
 
Apache Spark超入門 (Hadoop / Spark Conference Japan 2016 講演資料)
Apache Spark超入門 (Hadoop / Spark Conference Japan 2016 講演資料)Apache Spark超入門 (Hadoop / Spark Conference Japan 2016 講演資料)
Apache Spark超入門 (Hadoop / Spark Conference Japan 2016 講演資料)
 
Big-data analytics: challenges and opportunities
Big-data analytics: challenges and opportunitiesBig-data analytics: challenges and opportunities
Big-data analytics: challenges and opportunities
 
AngularJS Security: defend your Single Page Application
AngularJS Security: defend your Single Page Application AngularJS Security: defend your Single Page Application
AngularJS Security: defend your Single Page Application
 
[系列活動] 機器學習速遊
[系列活動] 機器學習速遊[系列活動] 機器學習速遊
[系列活動] 機器學習速遊
 
[DSC 2016] 系列活動:李宏毅 / 一天搞懂深度學習
[DSC 2016] 系列活動:李宏毅 / 一天搞懂深度學習[DSC 2016] 系列活動:李宏毅 / 一天搞懂深度學習
[DSC 2016] 系列活動:李宏毅 / 一天搞懂深度學習
 
[系列活動] 手把手的深度學習實務
[系列活動] 手把手的深度學習實務[系列活動] 手把手的深度學習實務
[系列活動] 手把手的深度學習實務
 
Powerpoint on environmental issues
Powerpoint on environmental issuesPowerpoint on environmental issues
Powerpoint on environmental issues
 

Similaire à 05 integrate redis

SenchaCon 2016: How to Auto Generate a Back-end in Minutes - Per Minborg, Emi...
SenchaCon 2016: How to Auto Generate a Back-end in Minutes - Per Minborg, Emi...SenchaCon 2016: How to Auto Generate a Back-end in Minutes - Per Minborg, Emi...
SenchaCon 2016: How to Auto Generate a Back-end in Minutes - Per Minborg, Emi...Sencha
 
SenchaCon 2016 - How to Auto Generate a Back-end in Minutes
SenchaCon 2016 - How to Auto Generate a Back-end in MinutesSenchaCon 2016 - How to Auto Generate a Back-end in Minutes
SenchaCon 2016 - How to Auto Generate a Back-end in MinutesMalin Weiss
 
SenchaCon 2016 - How to Auto Generate a Back-end in Minutes
SenchaCon 2016 - How to Auto Generate a Back-end in MinutesSenchaCon 2016 - How to Auto Generate a Back-end in Minutes
SenchaCon 2016 - How to Auto Generate a Back-end in MinutesSpeedment, Inc.
 
An introduction to the API for OnTime for IBM
An introduction to the API for OnTime for IBMAn introduction to the API for OnTime for IBM
An introduction to the API for OnTime for IBMontimesuite
 
Lessons learned while building Omroep.nl
Lessons learned while building Omroep.nlLessons learned while building Omroep.nl
Lessons learned while building Omroep.nltieleman
 
What's New in Apache Hive 3.0?
What's New in Apache Hive 3.0?What's New in Apache Hive 3.0?
What's New in Apache Hive 3.0?DataWorks Summit
 
What's New in Apache Hive 3.0 - Tokyo
What's New in Apache Hive 3.0 - TokyoWhat's New in Apache Hive 3.0 - Tokyo
What's New in Apache Hive 3.0 - TokyoDataWorks Summit
 
Utilizing the OpenNTF Domino API
Utilizing the OpenNTF Domino APIUtilizing the OpenNTF Domino API
Utilizing the OpenNTF Domino APIOliver Busse
 
Lessons learned while building Omroep.nl
Lessons learned while building Omroep.nlLessons learned while building Omroep.nl
Lessons learned while building Omroep.nlbartzon
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1Mohammad Qureshi
 
System insight without Interference
System insight without InterferenceSystem insight without Interference
System insight without InterferenceTony Tam
 
Utilizing the open ntf domino api
Utilizing the open ntf domino apiUtilizing the open ntf domino api
Utilizing the open ntf domino apiOliver Busse
 
Redis everywhere - PHP London
Redis everywhere - PHP LondonRedis everywhere - PHP London
Redis everywhere - PHP LondonRicard Clau
 
Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Ran Mizrahi
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Ran Mizrahi
 
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & MobileIVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & MobileAmazon Web Services Japan
 

Similaire à 05 integrate redis (20)

SenchaCon 2016: How to Auto Generate a Back-end in Minutes - Per Minborg, Emi...
SenchaCon 2016: How to Auto Generate a Back-end in Minutes - Per Minborg, Emi...SenchaCon 2016: How to Auto Generate a Back-end in Minutes - Per Minborg, Emi...
SenchaCon 2016: How to Auto Generate a Back-end in Minutes - Per Minborg, Emi...
 
SenchaCon 2016 - How to Auto Generate a Back-end in Minutes
SenchaCon 2016 - How to Auto Generate a Back-end in MinutesSenchaCon 2016 - How to Auto Generate a Back-end in Minutes
SenchaCon 2016 - How to Auto Generate a Back-end in Minutes
 
SenchaCon 2016 - How to Auto Generate a Back-end in Minutes
SenchaCon 2016 - How to Auto Generate a Back-end in MinutesSenchaCon 2016 - How to Auto Generate a Back-end in Minutes
SenchaCon 2016 - How to Auto Generate a Back-end in Minutes
 
An introduction to the API for OnTime for IBM
An introduction to the API for OnTime for IBMAn introduction to the API for OnTime for IBM
An introduction to the API for OnTime for IBM
 
Lessons learned while building Omroep.nl
Lessons learned while building Omroep.nlLessons learned while building Omroep.nl
Lessons learned while building Omroep.nl
 
What's New in Apache Hive 3.0?
What's New in Apache Hive 3.0?What's New in Apache Hive 3.0?
What's New in Apache Hive 3.0?
 
What's New in Apache Hive 3.0 - Tokyo
What's New in Apache Hive 3.0 - TokyoWhat's New in Apache Hive 3.0 - Tokyo
What's New in Apache Hive 3.0 - Tokyo
 
Utilizing the OpenNTF Domino API
Utilizing the OpenNTF Domino APIUtilizing the OpenNTF Domino API
Utilizing the OpenNTF Domino API
 
Lessons learned while building Omroep.nl
Lessons learned while building Omroep.nlLessons learned while building Omroep.nl
Lessons learned while building Omroep.nl
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
 
System insight without Interference
System insight without InterferenceSystem insight without Interference
System insight without Interference
 
Utilizing the open ntf domino api
Utilizing the open ntf domino apiUtilizing the open ntf domino api
Utilizing the open ntf domino api
 
Redis everywhere - PHP London
Redis everywhere - PHP LondonRedis everywhere - PHP London
Redis everywhere - PHP London
 
REDIS327
REDIS327REDIS327
REDIS327
 
Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)
 
Redis Labcamp
Redis LabcampRedis Labcamp
Redis Labcamp
 
Where to save my data, for devs!
Where to save my data, for devs!Where to save my data, for devs!
Where to save my data, for devs!
 
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & MobileIVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
 
Intro to CakePHP
Intro to CakePHPIntro to CakePHP
Intro to CakePHP
 

Plus de Erhwen Kuo

Datacon 2019-ksql-kubernetes-prometheus
Datacon 2019-ksql-kubernetes-prometheusDatacon 2019-ksql-kubernetes-prometheus
Datacon 2019-ksql-kubernetes-prometheusErhwen Kuo
 
Cncf k8s Ingress Example-03
Cncf k8s Ingress Example-03Cncf k8s Ingress Example-03
Cncf k8s Ingress Example-03Erhwen Kuo
 
Cncf k8s Ingress Example-02
Cncf k8s Ingress Example-02Cncf k8s Ingress Example-02
Cncf k8s Ingress Example-02Erhwen Kuo
 
Cncf k8s Ingress Example-01
Cncf k8s Ingress Example-01Cncf k8s Ingress Example-01
Cncf k8s Ingress Example-01Erhwen Kuo
 
Cncf k8s_network_03 (Ingress introduction)
Cncf k8s_network_03 (Ingress introduction)Cncf k8s_network_03 (Ingress introduction)
Cncf k8s_network_03 (Ingress introduction)Erhwen Kuo
 
Cncf k8s_network_02
Cncf k8s_network_02Cncf k8s_network_02
Cncf k8s_network_02Erhwen Kuo
 
Cncf k8s_network_part1
Cncf k8s_network_part1Cncf k8s_network_part1
Cncf k8s_network_part1Erhwen Kuo
 
Cncf explore k8s_api_go
Cncf explore k8s_api_goCncf explore k8s_api_go
Cncf explore k8s_api_goErhwen Kuo
 
CNCF explore k8s api using java client
CNCF explore k8s api using java clientCNCF explore k8s api using java client
CNCF explore k8s api using java clientErhwen Kuo
 
CNCF explore k8s_api
CNCF explore k8s_apiCNCF explore k8s_api
CNCF explore k8s_apiErhwen Kuo
 
Cncf Istio introduction
Cncf Istio introductionCncf Istio introduction
Cncf Istio introductionErhwen Kuo
 
TDEA 2018 Kafka EOS (Exactly-once)
TDEA 2018 Kafka EOS (Exactly-once)TDEA 2018 Kafka EOS (Exactly-once)
TDEA 2018 Kafka EOS (Exactly-once)Erhwen Kuo
 
啟動你的AI工匠魂
啟動你的AI工匠魂啟動你的AI工匠魂
啟動你的AI工匠魂Erhwen Kuo
 
Realtime analytics with Flink and Druid
Realtime analytics with Flink and DruidRealtime analytics with Flink and Druid
Realtime analytics with Flink and DruidErhwen Kuo
 

Plus de Erhwen Kuo (14)

Datacon 2019-ksql-kubernetes-prometheus
Datacon 2019-ksql-kubernetes-prometheusDatacon 2019-ksql-kubernetes-prometheus
Datacon 2019-ksql-kubernetes-prometheus
 
Cncf k8s Ingress Example-03
Cncf k8s Ingress Example-03Cncf k8s Ingress Example-03
Cncf k8s Ingress Example-03
 
Cncf k8s Ingress Example-02
Cncf k8s Ingress Example-02Cncf k8s Ingress Example-02
Cncf k8s Ingress Example-02
 
Cncf k8s Ingress Example-01
Cncf k8s Ingress Example-01Cncf k8s Ingress Example-01
Cncf k8s Ingress Example-01
 
Cncf k8s_network_03 (Ingress introduction)
Cncf k8s_network_03 (Ingress introduction)Cncf k8s_network_03 (Ingress introduction)
Cncf k8s_network_03 (Ingress introduction)
 
Cncf k8s_network_02
Cncf k8s_network_02Cncf k8s_network_02
Cncf k8s_network_02
 
Cncf k8s_network_part1
Cncf k8s_network_part1Cncf k8s_network_part1
Cncf k8s_network_part1
 
Cncf explore k8s_api_go
Cncf explore k8s_api_goCncf explore k8s_api_go
Cncf explore k8s_api_go
 
CNCF explore k8s api using java client
CNCF explore k8s api using java clientCNCF explore k8s api using java client
CNCF explore k8s api using java client
 
CNCF explore k8s_api
CNCF explore k8s_apiCNCF explore k8s_api
CNCF explore k8s_api
 
Cncf Istio introduction
Cncf Istio introductionCncf Istio introduction
Cncf Istio introduction
 
TDEA 2018 Kafka EOS (Exactly-once)
TDEA 2018 Kafka EOS (Exactly-once)TDEA 2018 Kafka EOS (Exactly-once)
TDEA 2018 Kafka EOS (Exactly-once)
 
啟動你的AI工匠魂
啟動你的AI工匠魂啟動你的AI工匠魂
啟動你的AI工匠魂
 
Realtime analytics with Flink and Druid
Realtime analytics with Flink and DruidRealtime analytics with Flink and Druid
Realtime analytics with Flink and Druid
 

Dernier

Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 

Dernier (20)

Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 

05 integrate redis

  • 1. AngularJS + Asp.Net Web Api, Signalr, EF6 + Redis:前後端 整合篇 開發技巧實戰系列(5/6) - Web 前後端整合 講師: 郭二文 (erhwenkuo@gmail.com)
  • 2. Document, Source code & Training Video (5/6) • https://github.com/erhwenkuo/PracticalCoding
  • 3. Previous Training Session Document, Source code & Training Video (4/6) • https://www.youtube.com/watch?v= AjEG65JTKKU • http://www.slideshare.net/erhwenku o/04-integrate-entityframework
  • 4. Agenda • StackOverflow Architecture • Redis Overview • Developing Asp.Net C# with Redis • Highchart , AngularJS ,Web API2 , SignalR2 , EF6 + Redis Integration
  • 6. “stackoverflow.com” Introduction • Stack Overflow is a question and answer web site for professional and enthusiast programmers • It's 100% free, no registration required • Rank#60 World-wide most popular web-site
  • 7. Some Number of stackoverflow • Ranked 54th for web-site traffic in the world • 4 million users • 40 million answers • 560 million pageviews a month • But…. Only 25servers used
  • 8. Architecture of stackoverflow • 2 load balancers, 1 active, using HAProxy • HAProxy is a free, very fast and reliable solution offering high availability, load balancing, and proxying for TCP and HTTP-based applications. • HAProxy is Open Source
  • 9. Architecture of stackoverflow • 9 web servers, using Microsoft IIS
  • 10. Architecture of stackoverflow • 2 machines for distributed cache and messaging using Redis
  • 11. Architecture of stackoverflow • 3 machines doing search with ElasticSearch
  • 12. Architecture of stackoverflow • 4 active database nodes, using MS SQL
  • 13. Architecture of stackoverflow • 3 application servers implementing the tag engine, anything searching by tag hits
  • 14. Architecture of stackoverflow • The UI has message inbox that is sent a message when you get a new badge, receive a message, significant event, etc. Done using WebSockets (SignalR) and is powered by redis (SignalR Redis Messaging Backplane )
  • 15. Software Stack & Result • Marco Cecconi - "The Architecture of StackOverflow“ • Youtube: https://www.youtube.com/watch?v=t6kM2EM6so4 • Details Info: http://highscalability.com/blog/2014/7/21/stackoverflow-update-560m- pageviews-a-month-25-servers-and-i.html
  • 16. Caching Strategy @ stackoverflow • Cache all the things • 5 levels of caches • 1st: is the network level cache: caching in the browser, CDN, and proxies • 2nd: given for free by the .Net framework and is called the HttpRuntime.Cache. An in- memory, per server cache • 3rd: Redis. Distributed in-memory key-value store. Share cache elements across different servers that serve the same site. If StackOverflow has 9 servers then all servers will be able to find the same cached items. • 4th: SQL Server Cache. The entire database is cached in-memory • 5th: SSD. Usually only hit when the SQL server cache is warming up
  • 19. What’s Redis • Redis is an open source, BSD licensed, advanced key-value cache and store. • It is often referred to as a data structure server, since keys can contain: • String • Hash • List • Set • Sorted Set • Bitmap • Hyperloglog
  • 20. Installing Redis • Suggest runing Redis on Linux for PRD environment • Run Redis on Windows for DEV environment or Testing purpose
  • 22. Download Redis • Get the latest Win64 release from Microsoft Github • https://github.com/MSOpenTech/redis/tree/2.8/bin/release • Download “redis-2.8.17.zip” and extract to specific folder
  • 23. Run Redis Server • Used text editor to modify “redis.windows.conf” • Comment out “maxheap” and set the value to “1073741824(1GB)” • Open a Windows command console & type in: • “redis-server redis.windows.conf” 1 2 3
  • 24. Using Redis Command Console Client • Open a Windows command console & type in: • “redis-cli” 1 2
  • 25. Redis Commands: Get & Set • Redis is a key-value store. By issuing the command “SET {key} {value}” you set the value of {value} to {key}.
  • 26. Redis Commands: Expire & Ttl • You can set keys to expire in a given amount of time by using the command, EXPIRE. • EXPIRE {key} {total_live_in_seconds} • TTL reports the time remaining before the key expires. • TTL {key}
  • 27. Redis Data Structure: List • One of the distinguishing features of Redis is that the values of a key can be data- structures, rather than just values • Following commands pertain to List: • RPUSH, LPUSH, LLEN, LRANGE, LTRIM, LINDEX, LSET, LREM, LPOP, RPOP, BLPOP, BRPOP, RPOPLPUSH & SORT
  • 28. Redis Data Structure: Set • Set are similar to lists, except each element can occur only once. • Following commands pertain to Set: • SADD, SREM, SPOP, SMOVE, SCARD, SISMEMBER, SINTER, SINTERSTORE, SUNION, SUNIONSTORE, SDIFF, SDIFFSTORE, SMEMBERS, SRANDMEMBER
  • 29. Redis Data Structure: Hash • Using a Hash, you can assign values to fields in each key. • Following commands pertain to Hash: • HSET, HGET, HSETNX, HMSET, HMGET, HINCRBY, HEXISTS, HDEL, HLEN, HKEYS, HVALS, HGETALL
  • 30. Redis Commands • Redis All Commands: http://redis.io/commands Different data structures that Redis support Redis command for specific data structure
  • 32. Environment Setup – Redis C# Client 1. Use NuGet to search “StackExchange.Redis” (C# redis client) 2. Click “Install”
  • 33. Environment Setup – Redis Desktop Manger 1. Download “Redis Desktop Manager” • https://github.com/uglide/RedisDesktopManager/rele ases/download/0.7.6/redis-desktop-manager- 0.7.6.15.exe 2. Click “Install”
  • 34. Redis in Practice#1 – WebApi Call Counts by Day • Potential for massive amounts of simple writes / reads • Valuable data, but not mission critical • Lots of row contention in SQL
  • 35. Redis in Practice#1 – WebApi Call Counts by Day • What: Records Web API POST/PUT/GET/DELETE events • {Url: “/api/Employees” , Method: “post” } • When: Records When Web API events occurred • {EventDate: 2014/12/22 10:00:00} • Where: Records Which Web API Provider • {Host: “server01”}
  • 36. Redis in Practice#1 – WebApi Call Counts by Day webapi_call_count_by_day:yyyy-mm-dd:server01 employees:post 1024 Redis: Hash data structure: {MetricName}:{When}:{Where} {What} Something we want to know (Counter) Key HashValueHashKey
  • 37. Redis in Practice#1 – WebApi Call Counts by Day 1. Create a new C# class “RedisConnHelper.cs” to get redis connection object 2. Create a new C# POCO class “Employee.cs” as domain model entity 3. Modify “EF6DbContext.cs” include EF6 ORM support for “Employee.cs” 4. Execute “Add-Migration AddEmployee” and “Update- Database” in “Package Manager Console” 5. Add new web api controller named “EmployeesControllers.cs”
  • 38. Redis in Practice#1 – WebApi Call Counts by Day (EmployeesController)
  • 39. Redis in Practice#1 – WebApi Call Counts by Day 1. Hit “F5” to run “PracticalCoding.Web” 2. Use “Fiddler2” to test below Web APIs (“/api/Employees”) 3. Use “Redis Desktop Manger” to see the Metric result Demo
  • 40. Redis in Practice#2 – Realtime Metrics • Traditionally, metrics are performed by a batch job (running hourly, daily, etc.) • Redis backed bitmaps allow us to perform such calculations in realtime and are extremely space efficient.
  • 41. Crash Course on Bitmap and Redis Bitmaps • Bitmap (aka Bitset) • A Bitmap or bitset is an array of zeros and ones. • A bit in a bitset can be set to either 0 or 1 • Eeach position in the array is referred to as an offset • Redis support Bit Operations such as logical AND, OR, XOR & NOT • Bitmaps in Redis • Redis allows binary keys and binary values • The setbit(key, offset, value) operation, which takes O(1) time, sets the value of a bit to 0 or 1 at the specified offset for a given key. The setbit(key, offset, value) operation, which takes O(1) time, sets the value of a bit to 0 or 1 at the specified offset for a given key.
  • 42. Population Count • The population count of a Bitmap is the total number of bits set to 1. The setbit(key, offset, value) operation, which takes O(1) time, sets the value of a bit to 0 or 1 at the specified offset for a given key.
  • 43. A Simple Example: Daily Active Users • Purpose: To count unique users that logged in today • HowTo: • We set up a bitmap where each user is identified by an offset value • When a user visits a page or performs an action, which warrants it to be counted, set the bit to 1 at the offset representing user id • The key for the bitmap is a function of the name of the action user performed and the timestamp • Every time a user logs in we perform: • redis.setbit(daily_active_users, user_id, 1) The setbit(key, offset, value) operation, which takes O(1) time, sets the value of a bit to 0 or 1 at the specified offset for a given key.
  • 44. A Simple Example: Daily Active Users (Session_05_UnitTest.Bitmap_Test.cs) The setbit(key, offset, value) operation, which takes O(1) time, sets the value of a bit to 0 or 1 at the specified offset for a given key.
  • 45. A Simple Example: Daily Active Users (Session_05_UnitTest.Bitmap_Test.cs) The setbit(key, offset, value) operation, which takes O(1) time, sets the value of a bit to 0 or 1 at the specified offset for a given key. Demo In my laptop, it can reach around 400K op/s through put!! The BitCount is very space efficient and also the speed is fast!!
  • 46. A Simple Example: Daily Active Users (Session_05_UnitTest.Bitmap_Test.cs) The setbit(key, offset, value) operation, which takes O(1) time, sets the value of a bit to 0 or 1 at the specified offset for a given key. Demo In my laptop, it can reach around 400Kop/s through put!! The BitCount is very space efficient and also the speed is fast!!
  • 47. Redis in Practice#3 – Redis as Datastore • “Memory is the new disk, disk is the new tape” – Jim Gray • Twitter Uses Redis To Scale - 105TB RAM, 39MM QPS, 10,000+ Instances • http://highscalability.com/blog/2014/9/8/how-twitter-uses-redis-to-scale- 105tb-ram-39mm-qps-10000-ins.html
  • 48. Environment Setup 1. Use NuGet to search “NServiceKit.Redis” 2. Click “Install”
  • 49. A Simple Example: Daily Active Users (Session_05_UnitTest. Datastore_Test.cs) The setbit(key, offset, value) operation, which takes O(1) time, sets the value of a bit to 0 or 1 at the specified offset for a given key. Demo
  • 50. Highchart , AngularJS ,Web API2 , SignalR2 , EF6 + Redis Integration
  • 51. Integration with Entity Framework • Copy “09_IntegrationWithEF6” to “10_IntegrationWithRedis ”
  • 54. Switch “EF6DashboardRepo” to “RedisDashboardRepo” • Copy “EF6DashboardController.cs” to “RedisDashboardController.cs” Switch our Repository from “EF6” to “redis” Dispose “RedisClient” connection object to release redis client connection
  • 55. Modify Our Angular “ChartDataFactory” • Switch angular $http communication end point to our new WebAPI url Before After
  • 56. Integration with Redis 1. Select “10_Integration/index.html” and Hit “F5” to run 2. Open Multi-Browers to see charts reflect changes whenever C/U/D operations occurred Demo
  • 57. Next Session: AngularJS , Highchart , Asp.Net WebApi2 , SignalR2 , EF6 , Redis + Elasticsearch

Notes de l'éditeur

  1. 開發技巧實戰 1. AngularJS入門篇 2. AngularJS + HighChart:完美網頁圖表整合篇 3. AngularJS + Asp.Net WebApi 2 +SignalR:前後端整合篇 4. AngularJS + Asp.Net WebApi 2+ SignalR + Entity Framework 6 (ORM):前後端整合篇 5. AngularJS + Asp.Net WebApi 2+ SignalR +Entity Framework 6 (ORM) + Redis (Nosql):前後端整合篇 6. AngularJS + Asp.Net WebApi 2+ SignalR +Entity Framework 6 (ORM) + Redis (Nosql) + Elasticsearch (全文檢索):前後端整合篇
  2. 本章節的內容會延續前一個Session的知識與內容, 如果對前一章節不熟悉的話, 可以在Yoube或Slideshare找到文件與教學錄影