Lighthouse Scanner: Stateless NodeJS Microservices with Redis DB

Which Database to Choose?

Redis Basics

  • Strings
  • Hashmaps
  • Lists, Sets, Ordered Sets
client@redis> lpush jobs:list job1 job2 job3
(integer) 3
client@redis> lrange jobs:list 0 -1
1) "job3"
2) "job2"
3) "job1"
client@redis> lpop jobs:list
client@redis> lrange jobs:list 0 -1
1) "job2"
2) "job1"

Building a Stateless Microservice

  • All data must be persisted immediately
  • Persisting and Reading must be fast and efficient
  • Working data must be deleted easily
  • Create and update a job
  • Create a report


  • A job object consists of uuid, domain and status.
  • The uuid is the identifier
  • The status changes from created to finish or error
  • The domain is used to retrieve the scan report once it is finished
hset "0b25ab16-6efd-485c-b260-1766505a3811" domain "" status "started"
hgetall "0b25ab16-6efd-485c-b260-1766505a3811"
1) "domain"
2) ""
3) "status"
4) "started"
hset "0b25ab16-6efd-485c-b260-1766505a3811" status "finished"
expire "0b25ab16-6efd-485c-b260-1766505a3811" 86400


set "" "<!doctype html><html lang=\"en\"><head><meta charset=\"utf-8\"> ..."
get ""

NodeJS Wrapper

redis.hset("0b25ab16-6efd-485c-b260-1766505a3811", "domain", "", "status", "started")
function updateJob(uuid, details) {
redis.hset(uuid, 'domain', details.domain, 'status', details.status);
redis.expire(uuid, 86400);




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store