making session stores more intelligent - qcon san francisco · 2020-05-14 · couchbase cassandra...
TRANSCRIPT
![Page 1: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/1.jpg)
Making Session Stores More IntelligentKYLE J. DAVIS
TECHNICAL MARKETING MANAGER
REDIS LABS
![Page 2: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/2.jpg)
Whatisasessionstore?
![Page 3: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/3.jpg)
• Anchunkofdatathatisconnectedtoone“user”ofaservice– ”user”canbeasimplevisitor– orproperuserwithanaccount
• Oftenpersistedbetweenclientandserverbyatokeninacookie*– Cookieisgivenbyserver,storedbybrowser– Clientsendsthatcookiebacktotheserveronsubsequentrequests– Serverassociatesthattokenwithdata
• Oftenthemostfrequentlyuseddatabythatuser– Datathatisspecifictotheuser– Datathatisrequiredforrenderingorcommonuse
• Oftenephemeralandduplicated
Asessionstoreis…
![Page 4: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/4.jpg)
Session Storage Uses Cases
Traditional• Username• Preferences• Name• “Stateful” data
Intelligent• Traditional +• Notifications• Past behaviour– content surfacing– analytical information– personalization
![Page 5: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/5.jpg)
In a simple world
Internet Server Database
![Page 6: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/6.jpg)
Good problems
Internet Server DatabaseTraffic Grows… Struggles
![Page 7: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/7.jpg)
Good solution
Internet Server Database
performance restored
Session storage on the server
![Page 8: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/8.jpg)
More good problems
Internet Server DatabaseSession storage
on the server
Struggling
![Page 9: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/9.jpg)
Problematic Solutions
Internet Server DatabaseSession storage
on the server
Load balanced
Session storage on the server
![Page 10: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/10.jpg)
Multiple Servers + On-server Sessions?
Server DatabaseRobin
Server#1– HelloRobin!
![Page 11: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/11.jpg)
Multiple Servers + On-server Sessions?
Server DatabaseRobin
Server#3– Hello????
![Page 12: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/12.jpg)
Better solution
Internet Server Database
Load balanced
RedisSession Storage
![Page 13: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/13.jpg)
WhatisRedis?
![Page 14: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/14.jpg)
WhoWeAre
Opensource.Theleadingin-memorydatabaseplatform,supportinganyhighperformanceoperational,analyticsorhybridusecase.
TheopensourcehomeandcommercialproviderofRedisEnterprisetechnology,platform,products&services.
14
![Page 15: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/15.jpg)
RedisTopDifferentiators
Simplicity ExtensibilityPerformanceNoSQLBenchmark
1
Redis DataStructures
2 3
Redis Modules
15
Lists
Hashes
Bitmaps
Strings
Bitfield
Streams
Hyperloglog
SortedSets
Sets
GeospatialIndexes
![Page 16: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/16.jpg)
Performance:TheMostPowerfulDatabase
HighestThroughputatLowestLatencyinHighVolumeofWritesScenario
LeastServersNeededtoDeliver1MillionWrites/Sec
BenchmarksperformedbyAvalonConsultingGroup BenchmarkspublishedintheGoogleblog
16
1
Serversu
sedtoachieve1Mwrites/sec
10k
20k
30k
40k
0
100
200
300
400
500
0Couchbase Cassandra Datastax Redise
394.42 381.31 372.31
71.22App
licat
ion
requ
ests
/sec
Latency in Milliseconds
Applica!on Latency (msec)
CouchbaseCassandra Redise
$14,832$371,040$2,226,216
25X150X
ANNUAL COST
COST COMPAREDTO REDISe
350
300
250
200
150
100
50
0
![Page 17: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/17.jpg)
Simplicity: DataStructures- Redis’BuildingBlocks
Lists[A→B→C→D→E]
Hashes{A:“foo”,B:“bar”,C:“baz”}
Bitmaps0011010101100111001010
Strings"I'maPlainTextString!”
Bitfield{23334}{112345569}{766538}
Key
17
2
”Retrievethee-mailaddressoftheuserwiththehighestbidinanauctionthatstartedonJuly24that11:00pmPST” ZREVRANGE07242015_230000=
Streamsà{id1=time1.seq1(A:“xyz”,B:“cdf”),
d2=time2.seq2(D:“abc”,)}à
Hyperloglog0011010111001110
SortedSets{A:0.1,B:0.3,C:100 }
Sets{A,B,C,D,E}
GeospatialIndexes{A:(51.5,0.12),B:(32.1,34.7)}
![Page 18: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/18.jpg)
• Add-onsthatuseaRedisAPItoseamlesslysupportadditionalusecasesanddatastructures.
• EnjoyRedis’simplicity,superhighperformance,infinitescalabilityandhighavailability.
Extensibility: ModulesExtendRedisInfinitely
• AnyC/C++/GoprogramcanbecomeaModuleandrunonRedis.
• Leverageexistingdatastructuresorintroducenewones.
• Canbeusedbyanyone;RedisEnterpriseModulesaretestedandcertifiedbyRedisLabs.
• TurnRedisintoaMulti-Model database
18
3
![Page 19: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/19.jpg)
Redise PackManagedFullymanagedRedise
Packinprivatedatacenters
Redise PackDownloadableRedisesoftwareforany
enterprisedatacenterorcloudenvironment
Redise CloudPrivateFullymanaged,server-lessscalingRedise
serviceinVPCswithinAWS,MSAzure,GCPandIBMSoftlayer
Redise CloudFullymanaged,server-lessRedise serviceonhostedresources
withinAWS,MSAzure,GCP,IBMSoftlayer,Heroku,CFand
OpenShift
RedisLabsProducts
19
or or or
DBaaS Software
![Page 20: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/20.jpg)
Concepts
![Page 21: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/21.jpg)
• Probabilisticdatastructure• Hash->samplebits->setbits• Properties:– Falsenegatives– notpossible– Falsepositives– possible,butcontrollable– Bitsperitemstored– Addorcheckifexists– LiketheTardis,it’sbiggerontheinsidethanoutside
• Availability:– Redis Module– Ontopofbitfields
Concept:BloomFilters(presence)
![Page 22: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/22.jpg)
• Probabilisticdatastructure• Hash->countruns->storeruns• Properties:– Estimatesuniqueitems– Bitsperitemstored– 264uniqueitemsin12kb/errorrate0.81%– Add,countormerge!– LiketheTardis,it’sbiggerontheinsidethanoutside
• Availability:– AllversionsofRedis
Concept:HyperLogLog (cardinality)
engineering.conversantmedia.com
![Page 23: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/23.jpg)
• It’sjustbits!• Fixedstartingpoint,eachpointrepresentsamomentintime,fliptorepresentactivity• Properties:– Sizerelativetolengthoftime(byteround)– Counttotalsorranges– BITOP(AND/XOR/OR/NOT)
• Availability:– AllversionsofRedis
Concept:Bitcounting(timeseries)
![Page 24: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/24.jpg)
GroupNotifications
![Page 25: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/25.jpg)
Process
• Groupofusersgetnotification“Saleonsweaters”• Insertintocentraltableofnotifications• Insertrowintablewitheachuserofgroupwithnotificationandseenflag• Eachtimeitisneeded,querynotificationstablewhereseenflagisfalse.
TraditionalGroupNotificationPattern
![Page 26: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/26.jpg)
TraditionalGroupNotificationPatternChallenges
• Adding/removingmeanstouchingarowforeachuseringroup.– Fineforgroupsof10users,whatabout1million?– Alsomulti-step
• Storageisproportionaltosizeofgroupandnotifications• ConstantDBhits,noteasilycacheable• Setting“read”isDBwrite
![Page 27: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/27.jpg)
Process
• Addnotificationtosinglegroupbasedstructureortable(easilycacheable)• Firstn notificationsarereadbyallusersingroup.• Thenotificationsarecheckedtoseeiftheyareinasession-basedBloomfilterornot.• MarkreadbyaddingtoBloomfilterinsessionstore.
Modern&IntelligentGroupNotificationPattern
![Page 28: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/28.jpg)
Modern&IntelligentGroupNotificationPatternAdvantages
• Addinganotificationonlywritestoasingletable,singlerow.• Modelfitsuse– unreadassumed.• Fast.Checkingforread/writingreadisunrelatedtonumberofitemsinthefilter.Consistent.• ~5-bits peritem,butBloomfilterdoesn’talwaysgrow.• Gentlescaling
![Page 29: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/29.jpg)
Visual
Notification#1Notification#2Notification#3Notification#4Notification#5Notification#6
✔
✗✔
✗✔
✗
Notification#1Notification#2Notification#3Notification#4Notification#5Notification#6
✗
![Page 30: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/30.jpg)
FreshContent
![Page 31: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/31.jpg)
Process
• Handpickandrotateasmallnumberofcontent/items• StoredinDBtable• Servedoutdumblytousers
TraditionalContentSurfacingPattern(Basic)Challenges
• Mayservecontentmultipletimes• Freshnessislinkedtoamanualcuratorialprocess
![Page 32: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/32.jpg)
TraditionalContentSurfacingPattern(Advanced)
Process
• Batchprocessbuildscontentlisttosurfaceforeachuser• ListisstoredinDBTable• Servedouttouser• Rotatedonaschedule
Challenges
• NotReal-time• Mayservecontentmultipletimes• Un-cacheableDBcontent• Hardtoscale
![Page 33: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/33.jpg)
Process
• MiddlewareaddseachcontentreadtoaBloomfilterstoredinthesession• Featuredcontentlistisbuilt,canbeextensive.• FeatureditemsarecheckedvsBloomfilteron-the-fly
Modern&IntelligentContentSurfacingPatternAdvantages
• NoDBhitsforuser• Featuredcontentiscacheable• Willnottoshowcontentmultipletimesifread• Tinystoragerequirementsevenatscale• Freshnesscanbeachievedwithzero/lowhumaninput• Real-timerecordingofactivity–immediateimpactonfreshcontent
![Page 34: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/34.jpg)
Visual
Content#1Content#2Content#3Content#4Content#5Content#6
✔
✗✔
✗✔
✗
Content#1
Content#1
✗
Content#3
Content#5
![Page 35: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/35.jpg)
ActivityPatternMonitoring&Personalization
![Page 36: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/36.jpg)
• Monitortheusagebehaviour– Contentviewed– Activityovertime– Combinationsofcontenthistoryandactivity
• Personalizethecontentbasedonthebehaviour• Seenasdifficulttoaccomplish– Analyticsdata
• Storedinanotherservice• Anonymized
– ComplicatedgraphorMLbasedsolutions• Inferences• Blackboxes
ActivityPatternMonitoring&Personalization?
![Page 37: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/37.jpg)
• Recordsiteactivitywithbitcounting• UniquepageviewsinHyperLogLog• LeveragethepagevisitBloomfilter• Simplercounterforpagesconsumed• Createcriteriabasedonsessionstoredanalytics– Newtoapage?Bloomfilter– Newtothesite?UniquePageview=1(HLL)&&PreviouslyVisited=false(Bloom)– Inactiveuser?Sumthebitcountoverthelastfiverecords,if=0theninactive– Beentoaclusterofpages(inferinterest)?CheckclusterofpagesvsBloomfilter– combo!
ActivityPatternMonitoring&Personalization
![Page 38: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/38.jpg)
• Whyisthissuddenlypossible?– Probabilisticdatastructuresaresmall/fast– Bitcountingissmall/fast– Decoupledfromoperationaldatabase
• Whataboutprivacy?– Legitimateconcern– Non-reversibleprobabilisticstructures– Siloed fromrestofdatabase
ActivityPatternMonitoring&Personalization
![Page 39: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/39.jpg)
Questions?
![Page 40: Making Session Stores More Intelligent - QCon San Francisco · 2020-05-14 · Couchbase Cassandra Datastax Redise 394.42 381.31 372.31 Application requests/sec 71.22 Latency in Milliseconds](https://reader034.vdocument.in/reader034/viewer/2022042219/5ec5d44ff62af96d47606304/html5/thumbnails/40.jpg)
Thankyou!Demosourcecode:https://github.com/stockholmux/qcon-redis-session-store-demo