HIGH PERFORMANCE SESSION
CHECKS
Mikael Lindström
Schibsted Payment
WHAT IS OUR SESSION CHECKS?





Javascript SDK send a session check request
SPiD backend extracts the cookie
Fetches session, client and user objects from MongoDB
Business logic validates the session and checks that the
client has access to the user
 Updates the session timestamp in MongoDB
 Returns some json data in a jsonp container
OLD IMPLEMENTATION
 PHP - implementation
 MongoDB – sessions and clients
PROBLEM
 Our PHP implementation does a lot of bootstrapping
 Loads and initiates unnecessary functionality for each
request
 Huge amount of requests to this specific endpoint
becomes a bottleneck
 Potentially called for each pageview on our clients.
NEW IMPLEMENTATION
 Nginx – ssl termination
 Node.js – implementation
 MongoDB – sessions and clients
TEST MACHINE





HP gen 8 blade
14 node worker processes
14 nginx processes
MongoDB session database

 Testing using LoadImpact (loadimpact.com)
RESULTS
 20 minutes
 7 million requests
 36 cups of coffee
PROBLEMS





Reading PHP sessions in node is hard
Cluster module unstable
Callback hell
Some modules we used was a bit unstable
CONCLUSION
 Solution was more complex than we initially thought. We
could have benefitted from a framework.
 Callbacks vs promises and yields
 Huge performance increase
 Bottleneck today is Nginx (ssl termination)
 ssl termination in Load Balancer
QUESTIONS?

High Performance Session Checks

  • 1.
    HIGH PERFORMANCE SESSION CHECKS MikaelLindström Schibsted Payment
  • 2.
    WHAT IS OURSESSION CHECKS?     Javascript SDK send a session check request SPiD backend extracts the cookie Fetches session, client and user objects from MongoDB Business logic validates the session and checks that the client has access to the user  Updates the session timestamp in MongoDB  Returns some json data in a jsonp container
  • 3.
    OLD IMPLEMENTATION  PHP- implementation  MongoDB – sessions and clients
  • 4.
    PROBLEM  Our PHPimplementation does a lot of bootstrapping  Loads and initiates unnecessary functionality for each request  Huge amount of requests to this specific endpoint becomes a bottleneck  Potentially called for each pageview on our clients.
  • 5.
    NEW IMPLEMENTATION  Nginx– ssl termination  Node.js – implementation  MongoDB – sessions and clients
  • 6.
    TEST MACHINE     HP gen8 blade 14 node worker processes 14 nginx processes MongoDB session database  Testing using LoadImpact (loadimpact.com)
  • 7.
    RESULTS  20 minutes 7 million requests  36 cups of coffee
  • 8.
    PROBLEMS     Reading PHP sessionsin node is hard Cluster module unstable Callback hell Some modules we used was a bit unstable
  • 9.
    CONCLUSION  Solution wasmore complex than we initially thought. We could have benefitted from a framework.  Callbacks vs promises and yields  Huge performance increase  Bottleneck today is Nginx (ssl termination)  ssl termination in Load Balancer
  • 10.