Upgrade to Pro — share decks privately, control downloads, hide ads and more …

From ColdFusion to GraphQL: Rapidly Refactoring...

Avatar for 6iix 6iix
October 08, 2019

From ColdFusion to GraphQL: Rapidly Refactoring A Legacy Application

SightBox builds a complex application using ColdFusion. Over time this became hard to maintain and extend. That led the team to investigate serverless solutions. With AWS AppSync, AWS Lambda, Amazon Aurora Serverless, and many other serverless services and tooling provided by Stackery, they learned how to rapidly refactor our application into a modern, efficient GraphQL service.

Avatar for 6iix

6iix

October 08, 2019

Other Decks in Programming

Transcript

  1. About Sightbox Sightbox is a new way for contact lense

    wearers to experience vision care. For an annual membership, we simplify the vision care experience by booking and paying for annual eye exams, managing prescriptions, and sending a yearly supply of contact lenses directly to our members’ door. 3
  2. Background • I fell in love with computers at a

    very young age • Helped a team connect a car to the internet • My first program was a calculator for algebra 4
  3. • Clear Boundaries • Makes new feature development easier •

    Can ship features sooner rather than later 12
  4. • Clear Boundaries • Isolation of data • Organization of

    resolvers • Multiple stacks allowing for faster development Blackbox GraphQL 23
  5. Cross Stack Communication • Exports are great for sharing resources

    across stacks. • This allows us to separate services and define boundaries 26
  6. • Bloated • Hard to navigate • Git conflicts are

    a problem GraphQL Schema Design 30
  7. • Allows for any folder structure (schema -> team ->

    service -> file.gql) • Compiled single file only at deploy time • Ownership is easy • Git Conflicts are easier to solve Multiple Files 31
  8. What is an AppSync Resolver A Resolver is a collection

    of functions that generate a response for a GraphQL query or mutation. 33
  9. Leverage Velocity Templates A velocity templates is a layer between

    the GraphQL request and your data store (DynamoDB, Lambda, Http, Sql) 37
  10. How they work 38 Request comes in, the request template

    is invoked, it formats a request to the data store. Once the data store responds the response template is invoked and formats the response for the client.
  11. In GraphQL the only data returned to the request, is

    the data that is requested and defined in the schema Data Design 40
  12. Template Design • “$context.arguments” accounts for query or mutation requests

    • “$context.source” accounts for nested resolvers 41
  13. • Use existing data source previously defined for the query

    • Use existing templates defined for the top level query • The only change is on TypeName and FieldName YAML Design 42
  14. • Clear Boundaries for team by separating resolvers • Multi

    file schema to define clear boundaries and contracts between teams. • Re-use of resolvers to cut down on duplicate resources and code Blackbox GraphQL Recap 43
  15. • Over 140 tables • Over 200 columns on single

    tables • Ad-hoc database design • Hosted on-site Where we started 45
  16. Converter Solution • Cron Jobs to migrate data • Not

    immediate • Hard to determine where in the conversion process you are 47
  17. • Only the GraphQL schema is designed for how you

    want your data to be. • Masks the problem, doesn’t solve it. Abstracted Strangling Method 48
  18. Strangler Pattern for DB • Follows the same pattern as

    code • Writes to both legacy and new data stores • Backwards compatible • Allows for incremental improvements • New features use the new data store. 49
  19. DynamoDB is a fully managed NoSQL database service that provides

    fast and predictable performance with seamless scalability. It has some upsides as well as some downsides. 51
  20. Amazon Aurora Serverless is an on-demand, auto-scaling configuration for Amazon

    Aurora (MySQL-compatible and PostgreSQL-compatible editions), where the database will automatically start up, shut down, and scale capacity up or down based on your application's needs. 55
  21. Stackery Serverless Aurora Add a resource > drag a resource

    inside of your VPC > fill out some values in the configuration screen > done. 58
  22. Pros • Easy (ish) Setup in CFN • Maintenance windows

    no more • Better security out of the gate • Data API 59
  23. Cons • Scaling is slow and effects your connection pool

    size • Cold Starts • Leaving it running all the time is not cost effective • Data Migrations are hard • Coordination of schemas across teams 60
  24. A Feature • Start small; A single function • Start

    with a single stack • I recommend a single read query • Have fun! 65
  25. Remember @BiIIMurray Parody Account Any pizza can be a personal

    pizza as long as you try hard enough and believe in yourself 66