SlideShare a Scribd company logo
1 of 27
Download to read offline
Wealthfront’s	
  Query	
  Engine	
  
Service	
  Framework	
  and	
  Standardized	
  RPC	
  

            julien@wealthfront.com	
  


                   March	
  8th,	
  2012	
  
Roadmap	
  
•    Query	
  Engine	
  
•    Queries	
  
•    Services	
  
•    Remote	
  Query	
  InvocaKon	
  
The	
  Query	
  Engine	
  is	
  
•    a	
  plaMorm	
  to	
  build	
  distributed	
  services	
  quickly	
  
•    designed	
  with	
  testability	
  in	
  mind	
  
•    powering	
  all	
  of	
  Wealthfront’s	
  backend	
  services	
  
•    running	
  on	
  the	
  JVM	
  
The	
  Query	
  Engine	
  is	
  not	
  
•  a	
  web	
  framework	
  
•  a	
  RESTful	
  web	
  service	
  
    –  a	
  query	
  is	
  a	
  funcKon,	
  not	
  a	
  resource	
  
•  Java-­‐specific	
  
Queries	
  
•  First-­‐class	
  ciKzens	
  
     –  Queries	
  can	
  be	
  passed	
  around	
  and	
  later	
  invoked	
  
•  Serializable	
  
     –  Queries	
  can	
  be	
  persisted	
  
•  Closed	
  with	
  their	
  dependencies	
  
•  Composable	
  units	
  of	
  work	
  
     –  Queries	
  can	
  invoke	
  other	
  queries	
  
     –  Queries	
  can	
  produce	
  other	
  queries	
  
•  Entry	
  points	
  into	
  our	
  backend	
  services	
  
     –  Services	
  can	
  invoke	
  queries	
  on	
  other	
  services	
  
     –  Queries	
  can	
  also	
  be	
  invoked	
  from	
  the	
  command	
  line	
  
Queries	
  (concretely)	
  
•    Queries	
  are	
  classes	
  
•    Constructors	
  define	
  input	
  parameters	
  
•    Instances	
  are	
  invokable	
  using	
  a	
  driver	
  
•    Dependencies	
  can	
  be	
  requested	
  at	
  run-­‐Kme	
  
•    InvocaKons	
  produce	
  a	
  result	
  
•    Queries	
  are	
  easy	
  to	
  test	
  
UNIX	
  Processes	
  

             stdin	
                   Environment	
  




                         Process	
  




stdout	
                                       Return	
  code	
  

                          stderr	
  
Queries	
  

Arguments	
                    Dependencies	
  




                   Query	
  




  Result	
                       ExcepKon	
  
Invoking	
  a	
  Query	
  
                   Query	
  Class	
  


Arguments	
  


                 Query	
  Instance	
     Dependencies	
  




                                             Driver	
  



                                                          Result	
  
Invoking	
  a	
  Query	
  
Query	
  Instance	
                                         Dependencies	
  




                                                                                 Run	
  



     Scoping	
   Monitoring	
     Retrying	
     TransacKng	
     InjecKng	
  



     Result	
  
Services	
  
•  A	
  collecKon	
  of	
  Queries	
  
    –  Usually	
  with	
  a	
  similar	
  purpose,	
  e.g.	
  all	
  the	
  queries	
  
       related	
  to	
  customer	
  management	
  
•  Able	
  to	
  saKsfy	
  the	
  dependencies	
  required	
  by	
  
   its	
  Queries	
  
    –  E.g.	
  access	
  to	
  the	
  customer	
  database,	
  connecKon	
  
       to	
  the	
  NASDAQ	
  NLS	
  feed,	
  …	
  
•  Queries	
  can	
  be	
  installed	
  in	
  different	
  services	
  
Remote	
  Query	
  InvocaKon	
  
•  Queries	
  are	
  remotely	
  invoked	
  by	
  doing	
  an	
  
   HTTP	
  POST	
  request	
  
•  Arguments	
  are	
  encoded	
  in	
  the	
  HTTP	
  request	
  
•  Results	
  are	
  returned	
  in	
  the	
  HTTP	
  response	
  
Request	
  SerializaKon	
  
•  Most	
  of	
  our	
  services	
  rely	
  on	
  the	
  so-­‐called	
  
   “qp0p1”	
  serializaKon	
  
    –  The	
  simple	
  name	
  of	
  the	
  invoked	
  query	
  is	
  passed	
  
       with	
  the	
  q	
  parameter	
  
    –  The	
  nth	
  argument	
  is	
  passed	
  with	
  the	
  pnth	
  
       parameter	
  
    –  Arguments	
  are	
  serialized	
  and	
  de-­‐serialized	
  to	
  and	
  
       from	
  strings	
  using	
  converters	
  
Hello(@OpKonal(“World”)	
  String):	
  String	
  


          Instan&a&on	
                Serializa&on	
  
          new	
  Hello(“Bob”)	
        q=Hello&p0=Bob	
  
          new	
  Hello(null)	
         q=Hello	
  
[julien@glados	
  ~]$	
  curl	
  um0:8085	
  -­‐-­‐data	
  'q=Hello&p0=Bob’	
  -­‐v	
  
>	
  POST	
  /	
  HTTP/1.1>	
  Content-­‐Length:	
  14	
  
>	
  Content-­‐Type:	
  applicaKon/x-­‐www-­‐form-­‐urlencoded	
  
>	
  	
  
>	
  q=Hello&p0=Bob	
  

<	
  HTTP/1.1	
  200	
  OK	
  
<	
  X-­‐KC-­‐TraceToken:	
  962dcf36-­‐9b25-­‐4731-­‐a022-­‐e054b925637c	
  
<	
  Server:	
  kawala	
  
<	
  Content-­‐Length:	
  11	
  

Hello,	
  Bob!	
  
Request	
  De-­‐serializaKon	
  
•  Services’	
  request	
  interpreters	
  de-­‐serialize	
  the	
  
   HTTP	
  POST	
  requests	
  and	
  create	
  instances	
  of	
  
   the	
  query	
  class	
  using	
  the	
  specified	
  arguments	
  
•  Then,	
  they	
  invoke	
  the	
  query	
  instance	
  using	
  a	
  
   driver	
  
Request	
  De-­‐serializaKon	
  

HTTP	
  POST	
  request	
     Request	
  Interpreter	
  


                                                                    Query	
  Class	
  


                                                  Arguments	
  


                                                                  Query	
  Instance	
  



                                          Driver	
  
Smart	
  Clients	
  
•  Queries	
  can	
  be	
  remotely	
  invoked	
  from	
  Java	
  
   code	
  using	
  smart	
  clients	
  
•  Smart	
  clients	
  analyze	
  the	
  bytecode	
  to	
  recover	
  
   the	
  arguments	
  passed	
  to	
  the	
  query	
  
   constructor	
  and	
  generate	
  the	
  HTTP	
  POST	
  
   request	
  
•  Smart	
  clients	
  also	
  de-­‐serialize	
  the	
  result	
  from	
  
   the	
  HTTP	
  response	
  (see	
  “Result	
  SerializaKon”)	
  
Smart	
  Clients	
  
                  Query	
  Class	
  


Arguments	
  


                Query	
  Instance	
  




                                        Smart	
  Client	
     HTTP	
  POST	
  request	
  
The	
  Life	
  of	
  a	
  Remote	
  Request	
  
                     Client	
                                                                                        Server	
  

                    Query	
  Class	
  

Arguments	
  

                  Query	
  Instance	
  



                                          Smart	
  Client	
     HTTP	
  POST	
  request	
     Request	
  Interpreter	
  


                                                                                                                                  Query	
  Class	
  

                                                                                                            Arguments	
  

                                                                                                                              Query	
  Instance	
  


                                                                                                        Driver	
  
Constructor	
  Requirements	
  
•  In	
  order	
  to	
  be	
  analyzable,	
  query	
  constructors	
  
   must	
  follow	
  strict	
  requirements	
  
    –  Basically,	
  they	
  should	
  only	
  assign	
  their	
  arguments	
  
       to	
  fields	
  

hwps://github.com/wealthfront/kawala/wiki/InstanKators	
  
Sugar	
  for	
  the	
  Constructor	
  
•    @OpKonal(“2011-­‐02-­‐25”)	
  LocalDate	
  
•    @OpKonal(“false”)	
  boolean	
  
•    OpKon<LocalDate>	
  
•    @PosiKve	
  int	
  age	
  
Early	
  ValidaKon	
  
•  Arguments	
  are	
  validated	
  when	
  instanKaKng	
  a	
  
   serialized	
  query	
  thanks	
  to	
  the	
  converters	
  

[julien@glados	
  ~]$	
  ikq	
  um0	
  GetUser	
  foo	
  
HTTP	
  Error	
  400:	
  For	
  input	
  string:	
  "foo”	
  
X-­‐KC-­‐TraceToken:	
  962dcf36-­‐9b25-­‐4731-­‐a022-­‐e054b925637c	
  
Server:	
  kawala	
  
ConnecKon:	
  close	
  
Result	
  SerializaKon	
  
•  Results	
  are	
  usually	
  serialized	
  as	
  
    –  JSON	
  
    –  Protobuf	
  
•  The	
  service	
  has	
  the	
  responsibility	
  to	
  serialize	
  
   the	
  result	
  of	
  a	
  query	
  with	
  the	
  proper	
  
   serializaKon	
  method	
  
•  Smart	
  clients	
  rely	
  on	
  the	
  same	
  logic	
  to	
  select	
  
   the	
  proper	
  de-­‐serializaKon	
  method	
  
Result	
  SerializaKon	
  

Return	
  Type	
                         Addi&onal	
  Constraints	
                Serializa&on	
  
ConverKble	
  type*	
                                                              JSON	
  value**	
  
T	
                                      T	
  annotated	
  with	
  @EnKty	
        JSON	
  object	
  
List<T>	
                                T	
  annotated	
  with	
  @EnKty	
        JSON	
  array	
  
Set<T>	
                                 T	
  annotated	
  with	
  @EnKty	
        JSON	
  array	
  
T	
  extends	
  Message	
                                                          Protobuf	
  
List<T	
  extends	
  Message>	
                                                    Protobuf	
  array	
  



*	
  As	
  specified	
  in	
  KachingMarshallers	
  
**	
  JSON	
  strings	
  are	
  returned	
  without	
  surrounding	
  quotes	
  
The	
  Life	
  of	
  a	
  Remote	
  InvocaKon	
  
                      Client	
                                                             Server	
  

                     Query	
  Class	
                            Request	
  Interpreter	
  

Arguments	
  
                                                                                                        Query	
  Class	
  

                   Query	
  Instance	
                                         Arguments	
  

                                                                                                    Query	
  Instance	
  
                                           Smart	
  Client	
  

                                                                            Driver	
  
      Result	
  


                                                                            Result	
  



                                                                          Serializer	
  
Query	
  InvocaKon	
  Summary	
  
•  Local	
  InvocaKon	
  
   QueryExecutor	
  executor	
  =	
  …	
  
   User	
  user	
  =	
  executor.submit(new	
  GetUser(Id.<User>	
  of(10));	
  


•  Remote	
  InvocaKon	
  
   SmartClient<UM>	
  um	
  =	
  …	
  
   User	
  user	
  =	
  um.invoke(new	
  GetUser(Id.<User>	
  of(10));	
  

More Related Content

What's hot

Clojure - An Introduction for Java Programmers
Clojure - An Introduction for Java ProgrammersClojure - An Introduction for Java Programmers
Clojure - An Introduction for Java Programmerselliando dias
 
Introduction of failsafe
Introduction of failsafeIntroduction of failsafe
Introduction of failsafeSunghyouk Bae
 
Clojure A Dynamic Programming Language for the JVM
Clojure A Dynamic Programming Language for the JVMClojure A Dynamic Programming Language for the JVM
Clojure A Dynamic Programming Language for the JVMelliando dias
 
Open Source Compiler Construction for the JVM
Open Source Compiler Construction for the JVMOpen Source Compiler Construction for the JVM
Open Source Compiler Construction for the JVMTom Lee
 
4장. Class Loader
4장. Class Loader4장. Class Loader
4장. Class Loader김 한도
 
(COSCUP 2015) A Beginner's Journey to Mozilla SpiderMonkey JS Engine
(COSCUP 2015) A Beginner's Journey to Mozilla SpiderMonkey JS Engine(COSCUP 2015) A Beginner's Journey to Mozilla SpiderMonkey JS Engine
(COSCUP 2015) A Beginner's Journey to Mozilla SpiderMonkey JS EngineZongXian Shen
 
The use of Symfony2 @ Overblog
The use of Symfony2 @ OverblogThe use of Symfony2 @ Overblog
The use of Symfony2 @ OverblogXavier Hausherr
 
Have Your Cake and Eat It Too: Meta-Programming Techniques for Java
Have Your Cake and Eat It Too: Meta-Programming Techniques for JavaHave Your Cake and Eat It Too: Meta-Programming Techniques for Java
Have Your Cake and Eat It Too: Meta-Programming Techniques for JavaHoward Lewis Ship
 
Clojure - An Introduction for Lisp Programmers
Clojure - An Introduction for Lisp ProgrammersClojure - An Introduction for Lisp Programmers
Clojure - An Introduction for Lisp Programmerselliando dias
 
Distributes objects and Rmi
Distributes objects and RmiDistributes objects and Rmi
Distributes objects and RmiMayank Jain
 

What's hot (12)

Clojure - An Introduction for Java Programmers
Clojure - An Introduction for Java ProgrammersClojure - An Introduction for Java Programmers
Clojure - An Introduction for Java Programmers
 
Introduction of failsafe
Introduction of failsafeIntroduction of failsafe
Introduction of failsafe
 
JavaOne 2010: OSGI Migrat
JavaOne 2010: OSGI MigratJavaOne 2010: OSGI Migrat
JavaOne 2010: OSGI Migrat
 
J2EE-assignment
 J2EE-assignment J2EE-assignment
J2EE-assignment
 
Clojure A Dynamic Programming Language for the JVM
Clojure A Dynamic Programming Language for the JVMClojure A Dynamic Programming Language for the JVM
Clojure A Dynamic Programming Language for the JVM
 
Open Source Compiler Construction for the JVM
Open Source Compiler Construction for the JVMOpen Source Compiler Construction for the JVM
Open Source Compiler Construction for the JVM
 
4장. Class Loader
4장. Class Loader4장. Class Loader
4장. Class Loader
 
(COSCUP 2015) A Beginner's Journey to Mozilla SpiderMonkey JS Engine
(COSCUP 2015) A Beginner's Journey to Mozilla SpiderMonkey JS Engine(COSCUP 2015) A Beginner's Journey to Mozilla SpiderMonkey JS Engine
(COSCUP 2015) A Beginner's Journey to Mozilla SpiderMonkey JS Engine
 
The use of Symfony2 @ Overblog
The use of Symfony2 @ OverblogThe use of Symfony2 @ Overblog
The use of Symfony2 @ Overblog
 
Have Your Cake and Eat It Too: Meta-Programming Techniques for Java
Have Your Cake and Eat It Too: Meta-Programming Techniques for JavaHave Your Cake and Eat It Too: Meta-Programming Techniques for Java
Have Your Cake and Eat It Too: Meta-Programming Techniques for Java
 
Clojure - An Introduction for Lisp Programmers
Clojure - An Introduction for Lisp ProgrammersClojure - An Introduction for Lisp Programmers
Clojure - An Introduction for Lisp Programmers
 
Distributes objects and Rmi
Distributes objects and RmiDistributes objects and Rmi
Distributes objects and Rmi
 

Similar to Wealthfront's Query Engine

RESTful modules in zf2
RESTful modules in zf2RESTful modules in zf2
RESTful modules in zf2Corley S.r.l.
 
Dealing with and learning from the sandbox
Dealing with and learning from the sandboxDealing with and learning from the sandbox
Dealing with and learning from the sandboxElaine Van Bergen
 
Dealing with and learning from the sandbox
Dealing with and learning from the sandboxDealing with and learning from the sandbox
Dealing with and learning from the sandboxElaine Van Bergen
 
A Service-Based Architecture for Multi-domain Search on the Web
A Service-Based Architecture for Multi-domain Search on the WebA Service-Based Architecture for Multi-domain Search on the Web
A Service-Based Architecture for Multi-domain Search on the WebAlessandro Bozzon
 
Advanced Server Integration with Data and Direct
Advanced Server Integration with Data and DirectAdvanced Server Integration with Data and Direct
Advanced Server Integration with Data and DirectSencha
 
Session 29 - Servlets - Part 5
Session 29 - Servlets - Part 5Session 29 - Servlets - Part 5
Session 29 - Servlets - Part 5PawanMM
 
Web Technologies in Java EE 7
Web Technologies in Java EE 7Web Technologies in Java EE 7
Web Technologies in Java EE 7Lukáš Fryč
 
Integrating GWT, Spring and Hibernate ORM
Integrating GWT, Spring and Hibernate ORMIntegrating GWT, Spring and Hibernate ORM
Integrating GWT, Spring and Hibernate ORMMarakana Inc.
 
API Testing with Open Source Code and Cucumber
API Testing with Open Source Code and CucumberAPI Testing with Open Source Code and Cucumber
API Testing with Open Source Code and CucumberSmartBear
 
Netty 4-based RPC System Development
Netty 4-based RPC System DevelopmentNetty 4-based RPC System Development
Netty 4-based RPC System DevelopmentAllan Huang
 
Mike Taulty OData (NxtGen User Group UK)
Mike Taulty OData (NxtGen User Group UK)Mike Taulty OData (NxtGen User Group UK)
Mike Taulty OData (NxtGen User Group UK)ukdpe
 
API Testing Using REST Assured with TestNG
API Testing Using REST Assured with TestNGAPI Testing Using REST Assured with TestNG
API Testing Using REST Assured with TestNGSiddharth Sharma
 
Kafka Summit SF 2017 - Kafka Stream Processing for Everyone with KSQL
Kafka Summit SF 2017 - Kafka Stream Processing for Everyone with KSQLKafka Summit SF 2017 - Kafka Stream Processing for Everyone with KSQL
Kafka Summit SF 2017 - Kafka Stream Processing for Everyone with KSQLconfluent
 
Session 31 - Session Management, Best Practices, Design Patterns in Web Apps
Session 31 - Session Management, Best Practices, Design Patterns in Web AppsSession 31 - Session Management, Best Practices, Design Patterns in Web Apps
Session 31 - Session Management, Best Practices, Design Patterns in Web AppsPawanMM
 
Session 30 - Servlets - Part 6
Session 30 - Servlets - Part 6Session 30 - Servlets - Part 6
Session 30 - Servlets - Part 6PawanMM
 
Workflow as code with Azure Durable Functions
Workflow as code with Azure Durable FunctionsWorkflow as code with Azure Durable Functions
Workflow as code with Azure Durable FunctionsMassimo Bonanni
 
SharePoint Saturday The Conference DC - How the client object model saved the...
SharePoint Saturday The Conference DC - How the client object model saved the...SharePoint Saturday The Conference DC - How the client object model saved the...
SharePoint Saturday The Conference DC - How the client object model saved the...Liam Cleary [MVP]
 
Real world Scala hAkking NLJUG JFall 2011
Real world Scala hAkking NLJUG JFall 2011Real world Scala hAkking NLJUG JFall 2011
Real world Scala hAkking NLJUG JFall 2011Raymond Roestenburg
 

Similar to Wealthfront's Query Engine (20)

RESTful modules in zf2
RESTful modules in zf2RESTful modules in zf2
RESTful modules in zf2
 
Dealing with and learning from the sandbox
Dealing with and learning from the sandboxDealing with and learning from the sandbox
Dealing with and learning from the sandbox
 
Dealing with and learning from the sandbox
Dealing with and learning from the sandboxDealing with and learning from the sandbox
Dealing with and learning from the sandbox
 
A Service-Based Architecture for Multi-domain Search on the Web
A Service-Based Architecture for Multi-domain Search on the WebA Service-Based Architecture for Multi-domain Search on the Web
A Service-Based Architecture for Multi-domain Search on the Web
 
Advanced Server Integration with Data and Direct
Advanced Server Integration with Data and DirectAdvanced Server Integration with Data and Direct
Advanced Server Integration with Data and Direct
 
Session 29 - Servlets - Part 5
Session 29 - Servlets - Part 5Session 29 - Servlets - Part 5
Session 29 - Servlets - Part 5
 
Web Technologies in Java EE 7
Web Technologies in Java EE 7Web Technologies in Java EE 7
Web Technologies in Java EE 7
 
Integrating GWT, Spring and Hibernate ORM
Integrating GWT, Spring and Hibernate ORMIntegrating GWT, Spring and Hibernate ORM
Integrating GWT, Spring and Hibernate ORM
 
API Testing with Open Source Code and Cucumber
API Testing with Open Source Code and CucumberAPI Testing with Open Source Code and Cucumber
API Testing with Open Source Code and Cucumber
 
Netty 4-based RPC System Development
Netty 4-based RPC System DevelopmentNetty 4-based RPC System Development
Netty 4-based RPC System Development
 
Servlet
ServletServlet
Servlet
 
Mike Taulty OData (NxtGen User Group UK)
Mike Taulty OData (NxtGen User Group UK)Mike Taulty OData (NxtGen User Group UK)
Mike Taulty OData (NxtGen User Group UK)
 
Olist Architecture v2.0
Olist Architecture v2.0Olist Architecture v2.0
Olist Architecture v2.0
 
API Testing Using REST Assured with TestNG
API Testing Using REST Assured with TestNGAPI Testing Using REST Assured with TestNG
API Testing Using REST Assured with TestNG
 
Kafka Summit SF 2017 - Kafka Stream Processing for Everyone with KSQL
Kafka Summit SF 2017 - Kafka Stream Processing for Everyone with KSQLKafka Summit SF 2017 - Kafka Stream Processing for Everyone with KSQL
Kafka Summit SF 2017 - Kafka Stream Processing for Everyone with KSQL
 
Session 31 - Session Management, Best Practices, Design Patterns in Web Apps
Session 31 - Session Management, Best Practices, Design Patterns in Web AppsSession 31 - Session Management, Best Practices, Design Patterns in Web Apps
Session 31 - Session Management, Best Practices, Design Patterns in Web Apps
 
Session 30 - Servlets - Part 6
Session 30 - Servlets - Part 6Session 30 - Servlets - Part 6
Session 30 - Servlets - Part 6
 
Workflow as code with Azure Durable Functions
Workflow as code with Azure Durable FunctionsWorkflow as code with Azure Durable Functions
Workflow as code with Azure Durable Functions
 
SharePoint Saturday The Conference DC - How the client object model saved the...
SharePoint Saturday The Conference DC - How the client object model saved the...SharePoint Saturday The Conference DC - How the client object model saved the...
SharePoint Saturday The Conference DC - How the client object model saved the...
 
Real world Scala hAkking NLJUG JFall 2011
Real world Scala hAkking NLJUG JFall 2011Real world Scala hAkking NLJUG JFall 2011
Real world Scala hAkking NLJUG JFall 2011
 

Recently uploaded

Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

Wealthfront's Query Engine

  • 1. Wealthfront’s  Query  Engine   Service  Framework  and  Standardized  RPC   julien@wealthfront.com   March  8th,  2012  
  • 2. Roadmap   •  Query  Engine   •  Queries   •  Services   •  Remote  Query  InvocaKon  
  • 3. The  Query  Engine  is   •  a  plaMorm  to  build  distributed  services  quickly   •  designed  with  testability  in  mind   •  powering  all  of  Wealthfront’s  backend  services   •  running  on  the  JVM  
  • 4. The  Query  Engine  is  not   •  a  web  framework   •  a  RESTful  web  service   –  a  query  is  a  funcKon,  not  a  resource   •  Java-­‐specific  
  • 5. Queries   •  First-­‐class  ciKzens   –  Queries  can  be  passed  around  and  later  invoked   •  Serializable   –  Queries  can  be  persisted   •  Closed  with  their  dependencies   •  Composable  units  of  work   –  Queries  can  invoke  other  queries   –  Queries  can  produce  other  queries   •  Entry  points  into  our  backend  services   –  Services  can  invoke  queries  on  other  services   –  Queries  can  also  be  invoked  from  the  command  line  
  • 6. Queries  (concretely)   •  Queries  are  classes   •  Constructors  define  input  parameters   •  Instances  are  invokable  using  a  driver   •  Dependencies  can  be  requested  at  run-­‐Kme   •  InvocaKons  produce  a  result   •  Queries  are  easy  to  test  
  • 7. UNIX  Processes   stdin   Environment   Process   stdout   Return  code   stderr  
  • 8. Queries   Arguments   Dependencies   Query   Result   ExcepKon  
  • 9. Invoking  a  Query   Query  Class   Arguments   Query  Instance   Dependencies   Driver   Result  
  • 10. Invoking  a  Query   Query  Instance   Dependencies   Run   Scoping   Monitoring   Retrying   TransacKng   InjecKng   Result  
  • 11. Services   •  A  collecKon  of  Queries   –  Usually  with  a  similar  purpose,  e.g.  all  the  queries   related  to  customer  management   •  Able  to  saKsfy  the  dependencies  required  by   its  Queries   –  E.g.  access  to  the  customer  database,  connecKon   to  the  NASDAQ  NLS  feed,  …   •  Queries  can  be  installed  in  different  services  
  • 12. Remote  Query  InvocaKon   •  Queries  are  remotely  invoked  by  doing  an   HTTP  POST  request   •  Arguments  are  encoded  in  the  HTTP  request   •  Results  are  returned  in  the  HTTP  response  
  • 13. Request  SerializaKon   •  Most  of  our  services  rely  on  the  so-­‐called   “qp0p1”  serializaKon   –  The  simple  name  of  the  invoked  query  is  passed   with  the  q  parameter   –  The  nth  argument  is  passed  with  the  pnth   parameter   –  Arguments  are  serialized  and  de-­‐serialized  to  and   from  strings  using  converters  
  • 14. Hello(@OpKonal(“World”)  String):  String   Instan&a&on   Serializa&on   new  Hello(“Bob”)   q=Hello&p0=Bob   new  Hello(null)   q=Hello  
  • 15. [julien@glados  ~]$  curl  um0:8085  -­‐-­‐data  'q=Hello&p0=Bob’  -­‐v   >  POST  /  HTTP/1.1>  Content-­‐Length:  14   >  Content-­‐Type:  applicaKon/x-­‐www-­‐form-­‐urlencoded   >     >  q=Hello&p0=Bob   <  HTTP/1.1  200  OK   <  X-­‐KC-­‐TraceToken:  962dcf36-­‐9b25-­‐4731-­‐a022-­‐e054b925637c   <  Server:  kawala   <  Content-­‐Length:  11   Hello,  Bob!  
  • 16. Request  De-­‐serializaKon   •  Services’  request  interpreters  de-­‐serialize  the   HTTP  POST  requests  and  create  instances  of   the  query  class  using  the  specified  arguments   •  Then,  they  invoke  the  query  instance  using  a   driver  
  • 17. Request  De-­‐serializaKon   HTTP  POST  request   Request  Interpreter   Query  Class   Arguments   Query  Instance   Driver  
  • 18. Smart  Clients   •  Queries  can  be  remotely  invoked  from  Java   code  using  smart  clients   •  Smart  clients  analyze  the  bytecode  to  recover   the  arguments  passed  to  the  query   constructor  and  generate  the  HTTP  POST   request   •  Smart  clients  also  de-­‐serialize  the  result  from   the  HTTP  response  (see  “Result  SerializaKon”)  
  • 19. Smart  Clients   Query  Class   Arguments   Query  Instance   Smart  Client   HTTP  POST  request  
  • 20. The  Life  of  a  Remote  Request   Client   Server   Query  Class   Arguments   Query  Instance   Smart  Client   HTTP  POST  request   Request  Interpreter   Query  Class   Arguments   Query  Instance   Driver  
  • 21. Constructor  Requirements   •  In  order  to  be  analyzable,  query  constructors   must  follow  strict  requirements   –  Basically,  they  should  only  assign  their  arguments   to  fields   hwps://github.com/wealthfront/kawala/wiki/InstanKators  
  • 22. Sugar  for  the  Constructor   •  @OpKonal(“2011-­‐02-­‐25”)  LocalDate   •  @OpKonal(“false”)  boolean   •  OpKon<LocalDate>   •  @PosiKve  int  age  
  • 23. Early  ValidaKon   •  Arguments  are  validated  when  instanKaKng  a   serialized  query  thanks  to  the  converters   [julien@glados  ~]$  ikq  um0  GetUser  foo   HTTP  Error  400:  For  input  string:  "foo”   X-­‐KC-­‐TraceToken:  962dcf36-­‐9b25-­‐4731-­‐a022-­‐e054b925637c   Server:  kawala   ConnecKon:  close  
  • 24. Result  SerializaKon   •  Results  are  usually  serialized  as   –  JSON   –  Protobuf   •  The  service  has  the  responsibility  to  serialize   the  result  of  a  query  with  the  proper   serializaKon  method   •  Smart  clients  rely  on  the  same  logic  to  select   the  proper  de-­‐serializaKon  method  
  • 25. Result  SerializaKon   Return  Type   Addi&onal  Constraints   Serializa&on   ConverKble  type*   JSON  value**   T   T  annotated  with  @EnKty   JSON  object   List<T>   T  annotated  with  @EnKty   JSON  array   Set<T>   T  annotated  with  @EnKty   JSON  array   T  extends  Message   Protobuf   List<T  extends  Message>   Protobuf  array   *  As  specified  in  KachingMarshallers   **  JSON  strings  are  returned  without  surrounding  quotes  
  • 26. The  Life  of  a  Remote  InvocaKon   Client   Server   Query  Class   Request  Interpreter   Arguments   Query  Class   Query  Instance   Arguments   Query  Instance   Smart  Client   Driver   Result   Result   Serializer  
  • 27. Query  InvocaKon  Summary   •  Local  InvocaKon   QueryExecutor  executor  =  …   User  user  =  executor.submit(new  GetUser(Id.<User>  of(10));   •  Remote  InvocaKon   SmartClient<UM>  um  =  …   User  user  =  um.invoke(new  GetUser(Id.<User>  of(10));