Giter Site home page Giter Site logo

hhy5277 / 3factor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hasura/3factor

0.0 1.0 0.0 200 KB

3factor app is an architecture pattern for modern fullstack apps. 3factor apps are fast to build and are highly scalable.

Home Page: https://3factor.app/

Ruby 0.41% HTML 35.63% CSS 63.96%

3factor's Introduction

3factor app

3factor app is an architecture pattern for modern full-stack apps. Today, it is possible to build apps that have high feature velocity and scalability from the get go. Jump to reference implementation.

We propose an architecture pattern which is composed of 3 factors:

  1. Realtime GraphQL
  2. Reliable eventing
  3. Async serverless

Consider a traditional food ordering application which moves to a 3factor architecture:

3 factor architecture

Factor #1: Realtime GraphQL

Use GraphQL for a very simple and flexible frontend developer workflow. GraphQL is a crucial component for delivering high feature velocity. Your GraphQL layer should also support the following 2 properties:

  • Low-latency: An end-user should see instant feedback of an action and not have to wait long on an API (<100ms ideal, upto 1 second at worst).
  • Support subscriptions: Consume information "realtime" from the backend via GraphQL Subscriptions. Avoid the use of continuous polling (thereby reducing resource consumption).

Read more...

Factor #2: Reliable eventing

Remove in-memory state manipulation in your backend APIs and persist them as atomic events instead. Having an immutable event log helps in crash recovery, replayability and observability among others. Your event system should have the following 2 properties:

  • Atomic: Mutations to the application state should atomically create event(s).
  • Reliable: Events once emitted should be delivered (to any consumer) atleast once.

Read more...

Factor #3: Async serverless

Write business logic as event handlers. Deploy these event handlers on serverless compute. Serverless minimizes backend ops and gives free scalability while being cost-efficient. The serverless backends should follow few best-practices:

  • Idempotent: The code should be prepared for atleast-once (for same event) delivery of events.
  • Out-of-order: Events may not be guaranteed to be received in the order of creation. The code should not depend on any expected sequence of events.

Read more...


In short, a 3factor app requires you to remove state from your code and put it in your datastore and/or event queues as much as possible. Cloud vendors make it easy to scale and replicate your datastore, event-queues and compute backend. Consuming asynchronous information and performing sync actions in the frontend requires a high-performant realtime GraphQL API.

An interesting sidenote: A 3factor app's architecture is analogous to the redux dataflow model on a react app, but applied to the fullstack.

Comparison to 12factor.net

The 3factor name is inspired from 12factor.net. 12factor.net, created 7 years ago by the folks at Heroku, is a guide/best-practices for creating microservices based applications for modern cloud. Although the name is similar, 3factor.app is actually an application design pattern.

Reference implementation

A complete step-by-step reference implementation for a 3factor app is available at: github.com/hasura/3factor-example

3factor's People

Contributors

coco98 avatar shahidhk avatar tirumaraiselvan avatar wawhal avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.