SlideShare a Scribd company logo
Webinar Slides: Real time Recommendations with Redis, Java and Websockets
Webinar Slides: Real time Recommendations with Redis, Java and Websockets
QuickBooks Self Employed
QuickBooks Self Employed
Bank Connection Flow
Recommend rules
based on user
behavior
• Backend analyzes your behavior,
and recommends rules.
• Increased the ‘wow’ factor of our product.
• People who accept the recommended rules are more likely to subscribe.
• > 60% acceptance rate
Recommending rules
This is enabled by…
Communication between:
• Browser and app servers using Web sockets
• Back end processes using Redis Pub/Sub
WebSockets
WebSockets is an application protocol.
Enables two way communication between Server
and Client.
Supported by the latest browsers and web servers.
Spring supports websockets.
Redis Pub/Sub
Publish to a channel
Subscribe to a pattern or a channel
Linear complexity for most operations O(N+M)
Architecture
Spring on the backend..
Spring-session
Spring-mvc
Spring-websockets
Spring-data-redis
Spring-*
And AngularJS on the front
AngularJS
SockJS – JS web socket client
StompJS – Text protocol over web socket
The sequence
Browser WebApp servers Worker processes
Create web socket
connection
Subscribe to queue
Create Redis Pub Sub
channel for user
Connect a Bank Relay bank connection
request to worker
Listen for bank connection
publish event
Connect to bank, Import
transactions, etc.
Publish to web socketInform user of successful
connection
Publish connection
successful event
①
②
③ ④ ⑤
⑥⑦⑧
Why Redis for Pub/Sub?
Our use case – Create and close channels
dynamically, 100s of times a minute.
1000s of channels (users) live at any given time.
For our use case, RabbitMQ did not perform.
Now, the workflow
When a user
launches the app
• Web socket connection
created.
• Subscribe to the user’s
topic.
The front end
_connect() – Connects the web
socket, subscribes to a queue
called
“/user/{username}/queue/user_rec
ommendation”.
fireCallbacks() – fire callbacks to
UI subscribers, informing them
about events.
Some spring web
socket config
• Assign “/queue” endpoint to
web sockets.
• Assign “/ws” to annotated
methods.
• Stomp endpoint is “/ws/ws-
init”
When a web socket
subscription occurs
… we create a Redis
PUBSUB channel.
• Every user has a unique
PUBSUB channel.
• Only the App process that
listens to the websocket
subscribes to the Redis
channel.
And this is what you
see in Redis
We do end up 1000s of channels,
but Redis doesn’t blink!
… RabbitMQ did not scale above
200 queues
User starts categorizing transactions
When it detects a possible rule,
it publishes a message to the user’s topic.
In the worker process
… and publishes the same message on the Web Socket
App Server receives Message
A rule recommendation.
And the user sees…
“PUBSUB CHANNELS”
gives an exact count of how many users are using the system at a given
time.
Why DevOps loves this
What about mobile?
Web socket supported in iOS and Android.
iOS – StarScream
Android - android-websockets
Stomp support not so great… but it’s there:
iOS – WebSocketStompKit
Android – Gozirra
You can use Web Sockets without stomp.
iOS Demo (Bank)
• Heavy lifting done by the back
end.
• Same User Experience across all
devices.
iOS Demo (Rules)
• Heavy lifting done by the back
end.
• Same User Experience across all
devices.
Q and A
Contact
Github - http://github.com/nsdiv
Email – ninad.divadkar @ gmail.com

More Related Content

What's hot (20)

PPTX
Leveraging Redis for System Monitoring by Adam McCormick of SBG - Redis Day S...
Redis Labs
 
PDF
Monitoring, the Prometheus Way - Julius Voltz, Prometheus
Docker, Inc.
 
PDF
Deploying Kafka at Dropbox, Mark Smith, Sean Fellows
confluent
 
PPTX
RedisConf18 - Designing a Redis Client for Humans
Redis Labs
 
PDF
Monitoring kubernetes across data center and cloud
Datadog
 
PPTX
SQL, Redis and Kubernetes by Paul Stanton of Windocks - Redis Day Seattle 2020
Redis Labs
 
PPTX
RedisConf17 - Operationalizing Redis at Scale
Redis Labs
 
PPTX
Load Balancing and Scaling with NGINX
NGINX, Inc.
 
PDF
Metrics Are Not Enough: Monitoring Apache Kafka and Streaming Applications
confluent
 
PDF
Oops! I started a broker | Yinon Kahta, Taboola
HostedbyConfluent
 
PPTX
Streaming in Practice - Putting Apache Kafka in Production
confluent
 
PDF
When to KSQL & When to Live the KStream (Dani Traphagen, Confluent) Kafka Sum...
confluent
 
PDF
Learnings from the Field. Lessons from Working with Dozens of Small & Large D...
HostedbyConfluent
 
PDF
Capacity Planning Your Kafka Cluster | Jason Bell, Digitalis
HostedbyConfluent
 
ODP
Kafka aws
Ariel Moskovich
 
PPTX
Introducing Venice
Yan Yan
 
PDF
Apache Kafka - Martin Podval
Martin Podval
 
PDF
RedisConf17 - Explosion of Data at the Edge in Equinix
Redis Labs
 
PPTX
Maximizing PHP Performance with NGINX
NGINX, Inc.
 
PDF
Introduction to Akka-Streams
dmantula
 
Leveraging Redis for System Monitoring by Adam McCormick of SBG - Redis Day S...
Redis Labs
 
Monitoring, the Prometheus Way - Julius Voltz, Prometheus
Docker, Inc.
 
Deploying Kafka at Dropbox, Mark Smith, Sean Fellows
confluent
 
RedisConf18 - Designing a Redis Client for Humans
Redis Labs
 
Monitoring kubernetes across data center and cloud
Datadog
 
SQL, Redis and Kubernetes by Paul Stanton of Windocks - Redis Day Seattle 2020
Redis Labs
 
RedisConf17 - Operationalizing Redis at Scale
Redis Labs
 
Load Balancing and Scaling with NGINX
NGINX, Inc.
 
Metrics Are Not Enough: Monitoring Apache Kafka and Streaming Applications
confluent
 
Oops! I started a broker | Yinon Kahta, Taboola
HostedbyConfluent
 
Streaming in Practice - Putting Apache Kafka in Production
confluent
 
When to KSQL & When to Live the KStream (Dani Traphagen, Confluent) Kafka Sum...
confluent
 
Learnings from the Field. Lessons from Working with Dozens of Small & Large D...
HostedbyConfluent
 
Capacity Planning Your Kafka Cluster | Jason Bell, Digitalis
HostedbyConfluent
 
Kafka aws
Ariel Moskovich
 
Introducing Venice
Yan Yan
 
Apache Kafka - Martin Podval
Martin Podval
 
RedisConf17 - Explosion of Data at the Edge in Equinix
Redis Labs
 
Maximizing PHP Performance with NGINX
NGINX, Inc.
 
Introduction to Akka-Streams
dmantula
 

Similar to Webinar Slides: Real time Recommendations with Redis, Java and Websockets (20)

PPTX
Real Time Recommendations Using WebSockets and Redis - Ninad Divadkar, Inuit
Redis Labs
 
PPT
Camelone-2012 HTML5 WebSocket ActiveMQ/Camel
Charles Moulliard
 
PPTX
Js remote conf
Bart Wood
 
PPTX
Training Webinar: Enterprise application performance with server push technol...
OutSystems
 
PPTX
Real-time Communication using SignalR and cloud
Radu Vunvulea
 
PDF
WebSocket Push Fallback - Transcript.pdf
ShaiAlmog1
 
PDF
Full Stack Bus with Javascript, RabbitMQ and Postal.js
Javier Arias Losada
 
PDF
Real time web apps
Sepehr Rasouli
 
PDF
Do More With Message Queue
Hean Hong Leong
 
PPTX
Real time websites and mobile apps with SignalR
Roy Cornelissen
 
KEY
High scale flavour
Tomas Doran
 
PDF
WebSockets with Spring 4
Sergi Almar i Graupera
 
PDF
Dev con kolkata 2012 websockets
SANKARSAN BOSE
 
PDF
Building and Scaling a WebSockets Pubsub System
Kapil Reddy
 
PPTX
Enhancing Mobile User Experience with WebSocket
Mauricio "Maltron" Leal
 
ODP
The Art of Message Queues - TEKX
Mike Willbanks
 
PPTX
Basic understanding of websocket and and REST API
divyabiru27
 
PPTX
Programming WebSockets with Glassfish and Grizzly
C2B2 Consulting
 
PDF
Backend & Frontend architecture scalability & websockets
Anne Jan Brouwer
 
PDF
Building Next Generation Real-Time Web Applications using Websockets
Naresh Chintalcheru
 
Real Time Recommendations Using WebSockets and Redis - Ninad Divadkar, Inuit
Redis Labs
 
Camelone-2012 HTML5 WebSocket ActiveMQ/Camel
Charles Moulliard
 
Js remote conf
Bart Wood
 
Training Webinar: Enterprise application performance with server push technol...
OutSystems
 
Real-time Communication using SignalR and cloud
Radu Vunvulea
 
WebSocket Push Fallback - Transcript.pdf
ShaiAlmog1
 
Full Stack Bus with Javascript, RabbitMQ and Postal.js
Javier Arias Losada
 
Real time web apps
Sepehr Rasouli
 
Do More With Message Queue
Hean Hong Leong
 
Real time websites and mobile apps with SignalR
Roy Cornelissen
 
High scale flavour
Tomas Doran
 
WebSockets with Spring 4
Sergi Almar i Graupera
 
Dev con kolkata 2012 websockets
SANKARSAN BOSE
 
Building and Scaling a WebSockets Pubsub System
Kapil Reddy
 
Enhancing Mobile User Experience with WebSocket
Mauricio "Maltron" Leal
 
The Art of Message Queues - TEKX
Mike Willbanks
 
Basic understanding of websocket and and REST API
divyabiru27
 
Programming WebSockets with Glassfish and Grizzly
C2B2 Consulting
 
Backend & Frontend architecture scalability & websockets
Anne Jan Brouwer
 
Building Next Generation Real-Time Web Applications using Websockets
Naresh Chintalcheru
 
Ad

More from Redis Labs (20)

PPTX
Redis Day Bangalore 2020 - Session state caching with redis
Redis Labs
 
PPTX
Protecting Your API with Redis by Jane Paek - Redis Day Seattle 2020
Redis Labs
 
PPTX
The Happy Marriage of Redis and Protobuf by Scott Haines of Twilio - Redis Da...
Redis Labs
 
PPTX
Rust and Redis - Solving Problems for Kubernetes by Ravi Jagannathan of VMwar...
Redis Labs
 
PPTX
Redis for Data Science and Engineering by Dmitry Polyakovsky of Oracle
Redis Labs
 
PPTX
Practical Use Cases for ACLs in Redis 6 by Jamie Scott - Redis Day Seattle 2020
Redis Labs
 
PPTX
Moving Beyond Cache by Yiftach Shoolman Redis Labs - Redis Day Seattle 2020
Redis Labs
 
PPTX
JSON in Redis - When to use RedisJSON by Jay Won of Coupang - Redis Day Seatt...
Redis Labs
 
PPTX
Highly Available Persistent Session Management Service by Mohamed Elmergawi o...
Redis Labs
 
PPTX
Anatomy of a Redis Command by Madelyn Olson of Amazon Web Services - Redis Da...
Redis Labs
 
PPTX
Building a Multi-dimensional Analytics Engine with RedisGraph by Matthew Goos...
Redis Labs
 
PPTX
RediSearch 1.6 by Pieter Cailliau - Redis Day Bangalore 2020
Redis Labs
 
PPTX
RedisGraph 2.0 by Pieter Cailliau - Redis Day Bangalore 2020
Redis Labs
 
PPTX
RedisTimeSeries 1.2 by Pieter Cailliau - Redis Day Bangalore 2020
Redis Labs
 
PPTX
RedisAI 0.9 by Sherin Thomas of Tensorwerk - Redis Day Bangalore 2020
Redis Labs
 
PPTX
Rate-Limiting 30 Million requests by Vijay Lakshminarayanan and Girish Koundi...
Redis Labs
 
PDF
Three Pillars of Observability by Rajalakshmi Raji Srinivasan of Site24x7 Zoh...
Redis Labs
 
PPTX
Solving Complex Scaling Problems by Prashant Kumar and Abhishek Jain of Myntr...
Redis Labs
 
PPTX
Redis as a High Scale Swiss Army Knife by Rahul Dagar and Abhishek Gupta of G...
Redis Labs
 
PPTX
Deploying Redis as a Sidecar in Kubernetes by Janakiram MSV - Redis Day Banga...
Redis Labs
 
Redis Day Bangalore 2020 - Session state caching with redis
Redis Labs
 
Protecting Your API with Redis by Jane Paek - Redis Day Seattle 2020
Redis Labs
 
The Happy Marriage of Redis and Protobuf by Scott Haines of Twilio - Redis Da...
Redis Labs
 
Rust and Redis - Solving Problems for Kubernetes by Ravi Jagannathan of VMwar...
Redis Labs
 
Redis for Data Science and Engineering by Dmitry Polyakovsky of Oracle
Redis Labs
 
Practical Use Cases for ACLs in Redis 6 by Jamie Scott - Redis Day Seattle 2020
Redis Labs
 
Moving Beyond Cache by Yiftach Shoolman Redis Labs - Redis Day Seattle 2020
Redis Labs
 
JSON in Redis - When to use RedisJSON by Jay Won of Coupang - Redis Day Seatt...
Redis Labs
 
Highly Available Persistent Session Management Service by Mohamed Elmergawi o...
Redis Labs
 
Anatomy of a Redis Command by Madelyn Olson of Amazon Web Services - Redis Da...
Redis Labs
 
Building a Multi-dimensional Analytics Engine with RedisGraph by Matthew Goos...
Redis Labs
 
RediSearch 1.6 by Pieter Cailliau - Redis Day Bangalore 2020
Redis Labs
 
RedisGraph 2.0 by Pieter Cailliau - Redis Day Bangalore 2020
Redis Labs
 
RedisTimeSeries 1.2 by Pieter Cailliau - Redis Day Bangalore 2020
Redis Labs
 
RedisAI 0.9 by Sherin Thomas of Tensorwerk - Redis Day Bangalore 2020
Redis Labs
 
Rate-Limiting 30 Million requests by Vijay Lakshminarayanan and Girish Koundi...
Redis Labs
 
Three Pillars of Observability by Rajalakshmi Raji Srinivasan of Site24x7 Zoh...
Redis Labs
 
Solving Complex Scaling Problems by Prashant Kumar and Abhishek Jain of Myntr...
Redis Labs
 
Redis as a High Scale Swiss Army Knife by Rahul Dagar and Abhishek Gupta of G...
Redis Labs
 
Deploying Redis as a Sidecar in Kubernetes by Janakiram MSV - Redis Day Banga...
Redis Labs
 
Ad

Recently uploaded (20)

PDF
IObit Driver Booster Pro 12.4.0.585 Crack Free Download
henryc1122g
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PDF
NPD Software -Omnex systems
omnex systems
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PPTX
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
PDF
intro_to_cpp_namespace_robotics_corner.pdf
MohamedSaied877003
 
PPTX
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
PDF
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
PPTX
Smart Doctor Appointment Booking option in odoo.pptx
AxisTechnolabs
 
PDF
Best Web development company in india 2025
Greenusys
 
PDF
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
PDF
AI Prompts Cheat Code prompt engineering
Avijit Kumar Roy
 
PDF
Ready Layer One: Intro to the Model Context Protocol
mmckenna1
 
PDF
UITP Summit Meep Pitch may 2025 MaaS Rebooted
campoamor1
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PPTX
Prompt Like a Pro. Leveraging Salesforce Data to Power AI Workflows.pptx
Dele Amefo
 
PDF
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
PDF
Everything you need to know about pricing & licensing Microsoft 365 Copilot f...
Q-Advise
 
IObit Driver Booster Pro 12.4.0.585 Crack Free Download
henryc1122g
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
NPD Software -Omnex systems
omnex systems
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
intro_to_cpp_namespace_robotics_corner.pdf
MohamedSaied877003
 
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
Smart Doctor Appointment Booking option in odoo.pptx
AxisTechnolabs
 
Best Web development company in india 2025
Greenusys
 
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
AI Prompts Cheat Code prompt engineering
Avijit Kumar Roy
 
Ready Layer One: Intro to the Model Context Protocol
mmckenna1
 
UITP Summit Meep Pitch may 2025 MaaS Rebooted
campoamor1
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
Prompt Like a Pro. Leveraging Salesforce Data to Power AI Workflows.pptx
Dele Amefo
 
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
Everything you need to know about pricing & licensing Microsoft 365 Copilot f...
Q-Advise
 

Webinar Slides: Real time Recommendations with Redis, Java and Websockets

  • 6. Recommend rules based on user behavior • Backend analyzes your behavior, and recommends rules.
  • 7. • Increased the ‘wow’ factor of our product. • People who accept the recommended rules are more likely to subscribe. • > 60% acceptance rate Recommending rules
  • 8. This is enabled by… Communication between: • Browser and app servers using Web sockets • Back end processes using Redis Pub/Sub
  • 9. WebSockets WebSockets is an application protocol. Enables two way communication between Server and Client. Supported by the latest browsers and web servers. Spring supports websockets.
  • 10. Redis Pub/Sub Publish to a channel Subscribe to a pattern or a channel Linear complexity for most operations O(N+M)
  • 12. Spring on the backend.. Spring-session Spring-mvc Spring-websockets Spring-data-redis Spring-*
  • 13. And AngularJS on the front AngularJS SockJS – JS web socket client StompJS – Text protocol over web socket
  • 14. The sequence Browser WebApp servers Worker processes Create web socket connection Subscribe to queue Create Redis Pub Sub channel for user Connect a Bank Relay bank connection request to worker Listen for bank connection publish event Connect to bank, Import transactions, etc. Publish to web socketInform user of successful connection Publish connection successful event ① ② ③ ④ ⑤ ⑥⑦⑧
  • 15. Why Redis for Pub/Sub? Our use case – Create and close channels dynamically, 100s of times a minute. 1000s of channels (users) live at any given time. For our use case, RabbitMQ did not perform.
  • 17. When a user launches the app • Web socket connection created. • Subscribe to the user’s topic.
  • 18. The front end _connect() – Connects the web socket, subscribes to a queue called “/user/{username}/queue/user_rec ommendation”. fireCallbacks() – fire callbacks to UI subscribers, informing them about events.
  • 19. Some spring web socket config • Assign “/queue” endpoint to web sockets. • Assign “/ws” to annotated methods. • Stomp endpoint is “/ws/ws- init”
  • 20. When a web socket subscription occurs … we create a Redis PUBSUB channel. • Every user has a unique PUBSUB channel. • Only the App process that listens to the websocket subscribes to the Redis channel.
  • 21. And this is what you see in Redis We do end up 1000s of channels, but Redis doesn’t blink! … RabbitMQ did not scale above 200 queues
  • 22. User starts categorizing transactions
  • 23. When it detects a possible rule, it publishes a message to the user’s topic. In the worker process
  • 24. … and publishes the same message on the Web Socket App Server receives Message
  • 25. A rule recommendation. And the user sees…
  • 26. “PUBSUB CHANNELS” gives an exact count of how many users are using the system at a given time. Why DevOps loves this
  • 27. What about mobile? Web socket supported in iOS and Android. iOS – StarScream Android - android-websockets Stomp support not so great… but it’s there: iOS – WebSocketStompKit Android – Gozirra You can use Web Sockets without stomp.
  • 28. iOS Demo (Bank) • Heavy lifting done by the back end. • Same User Experience across all devices.
  • 29. iOS Demo (Rules) • Heavy lifting done by the back end. • Same User Experience across all devices.

Editor's Notes

  • #2: Hello everybody, thank you for coming and welcome to my presentation. My name is Ninad Divadkar, and I’m going to talk about Real time recommendations using Web Sockets and Redis.
  • #3: A little bit about my self. I work for Intuit Inc in the QuickBooks Self Employed division. I’m a full stack developer, and although I have used quite a few different programming languages over the years, I’d say my backend expertise is in JAVA and .NET, and front end in AngularJS. I’m also a Spring contributor. My latest contribution is to the spring-data-redis project. Redis is introduced Geo commands in the latest version, and I have added support for those in spring-data-redis. In addition, I am active on stackoverflow, mainly in JavaScript, Java and Spring topics.
  • #4: Before we dive into the presentation, let me tell you about QuickBooks Self Employed, because it will help us understand our use case better. QuickBooks Self Employed helps self employed people – like artists, dancers, uber drivers, etc find tax deductions and be complaint with IRS rules and regulations. We do that by connecting to their bank and importing the bank transactions. Users then categorize these transactions as business or personal. Anything transaction categorized as a business expense can be a tax deduction. We have an interface so that users can pay the IRS their estimated taxes directly through our software. And we integrate with TurboTax for hassle free filing. In addition to our web presence, our iOS and Android apps help self employed people do mileage tracking. We launched a year and a half ago in the US, and have also launched the product in the UK, with more countries to follow shortly.
  • #5: Let me demo you our iOS app to show what the product does. Users categorize these transactions as business or personal. Users track their mileage, so, for example if they are working for Uber they can deduct the miles they drove their car for work. We give the users an overview of their finances, because many users do not have a great way of know whether they have a profit or not. And we integrate with TurboTax (which is also an Intuit product), so that users can easily file their taxes.
  • #6: Now, I’m going to demo two workflows in QuickBooks Self Employed that demonstrate how we use web sockets and Redis Pub/Sub in tandem. I’m just going to demo the UI, and as go further into the presentation, I’ll show you the architecture and deeper layers of our product. The first workflow is the Bank Connection Flow. After launching the app, the user is led to the ‘connect a bank account’ screen. The user selects a bank and enters his credentials. We support 10,000 plus banks and credit unions in the US. Connecting to a bank takes anywhere from 30 seconds to 5 minutes. During this time we’re communicating with a backend service that actually logs in to the bank and downloads transactions. This is a critical process in the user flow, almost a make or break point. We need to WOW the user, and make sure the user understands the value of our product. At this moment, we want the UI to be updated with what stage the back end is at in the process of connecting a bank.
  • #7: After the user has started categorizing transactions, the product learns from the categorization, and recommends rules to help the user save time. So if, for example, the user categorizes 3 Wal-mart transactions as business, we understand that he or she is going to categorize the rest as business as well. So the product pops up a recommendation to the user.
  • #8: Recommending rules to user has made our users very happy. When they start using the product, they learn the value right away. We have an over 60% rate of acceptance with our rule recommendation engine, and it is going up all the time. Best of all, it is a unified experience across web and mobile. The web as well as mobile apps use web-sockets to get the recommendations.
  • #9: These two workflows are enabled by….. Web Sockets for communicating between the front end (browser) and the back end. Redis Pub/Sub for communicating between back end processes.
  • #10: Some of you may be familiar with what websockets are, but let me spend a couple of minutes explaining: WebSockets is a application protocol, that works over TCP. The idea behind the WebSocket protocol consists of reusing the established TCP connection between a Client and Server. After the HTTP handshake, the Client and Server start speaking WebSocket protocol by exchanging WebSocket envelopes. What this means for us is that it allows two way communication in the browser. This allows us to communicate with the browser in message bus type fashion. Before web socket support, we used to have long polling and other stop gap measures, but they are not required anymore.
  • #11: Now, let’s move to Redis Pub/Sub. Most of us use Redis for caching, but Redis also has a very good pub/sub messaging framework built in. The terminology that Redis uses is a ‘channel’ instead of a ‘queue’ or a ‘topic’. A publisher publishes to a channel. A Subscriber subscribes to a channel or a pattern. These commands are super fast, and all of the pub/sub commands take linear time, O(n+m), where N is the number of clients subscribed directly to the channel and M is the number subscribed patterns.
  • #12: The architecture of our site. We have web app processes that serve requests coming in through our web app. We have API processes that serve API requests coming in through our mobile apps. We run embedded Tomcat 8 in both servers. We have worker processes who do the heavy lifting, allowing us to scale without having to increase our app and api processes. Intra process communication is done using Redis pub/sub, i.e. Web app and API processes communicate with the worker process using Redis Pub/Sub
  • #13: Spring is used extensively on the backend. We use a lot more Spring projects than shown above.
  • #14: SockJS is a browser JavaScript library that provides a WebSocket like object. Under the hood SockJS tries to use native WebSockets first. If that fails it can use a variety of browser-specific transport protocols and presents them through WebSocket-like abstractions. STOMP is a simple text messaging protocol, and stompJS implements that protocol. Spring supports it, and so we use it.
  • #16: The big question, why redis for Pub Sub. Our use case is a little different from regular use cases for RabbitMQ. RabbitMQ can handle thousands of messages a second, but it is not built to handle hundreds of queues being created dynamically in a minute. We went to production with RabbitMQ. We have multiple app servers, but a web socket is created to only one app server. That server needs to listen to a message sent by the worker process. So we need a unique queue per user. RabbitMQ performance dropped drastically after around 200 queues. CPU spiked and we had to drop the idea of using RabbitMQ. Instead of being able to create ~50 queues / sec, throughput dropped to ~2 queues / sec.
  • #17: Now, we’ll go through the entire workflow, of a user launching the app and seeing a recommendation.
  • #18: Creating a web socket connection is not enough. Web-sockets connection opens a pipe to the server. However you want to publish to a topic. That way different parts of the code can use different topics, just like on the back end.
  • #20: EnableWebSocketMessageBroker is the Spring annotation to enable broker backed mesasaging over webSocket. The MessageBrokerRegistry configuration reserves certain endpoints for websocket broker Stomp endpoint is ws-init, for regular cases
  • #21: We’re implementing an ApplicationListener where we are listening to the SessionSubscribeEvent. When a SessionSubscribeEvent occurs, we create a Redis Pub Sub channel for the user. Every user has a unique PUBSUB channel. And only the App process that listens to the websocket subscribes to the Redis channel. For example, if there are 5 app server taking requests, the web socket is connected to only 1 app server, and only that app server will subscribe to the user’s PUBSUB channel.
  • #22: During tax peak we had over 4k simultaneous users on our site.
  • #24: When the worker process detects a possible rule, it publishes a message to the user’s topic.
  • #27: An unexpected benefit of creating Redis channels whenever a user launches our app is that we can count the exact number of users who are on our site. Our DevOps has written a script that runs every minute and captures the number of live channels in Redis. The picture above is of a Splunk search where we have charted the number of users using our app over a 7 day period. Mind you this is after tax season is over. During tax season we had record traffic. Things like these help us understand how many users are using our web app or mobile apps at any given time, and how long they are staying on the site as well.
  • #28: Websockets are supported in both iOS and Android. There are quite a few open source libraries that work great. We are using https://github.com/daltoniam/Starscream in iOS and https://github.com/koush/android-websockets for android. There isn’t good support for Stomp. But that is not an issue. Spring has support for just Websockets without stomp. You’ll just have to make your own protocol, and for our use case it is not a problem. http://stackoverflow.com/questions/27158106/websocket-with-sockjs-spring-4-but-without-stomp
  • #31: Redis channel limits - https://groups.google.com/forum/#!topic/redis-db/G-rFG0k7NiY. At least up to 10k. We have tested until 5k simultaneous channels, our peak traffic has reached 4k simultaneous connections. Websockets for iOS and android – WebsocketStompKit (iOS), gozirra (android) while there is support, it is not well maintained. XMPP vs websocket - http://stackoverflow.com/questions/31108780/stomp-or-xmpp-over-websocket . Stomp is easier to implement in Spring