Giter Club home page Giter Club logo

go-multitenancy's Introduction

go-multitenancy

Multi-tenancy application using Database-per-tenant model.

Overview

  • A new database is provisioned for each new tenant.
  • The application tier is scaled up vertically by adding more resources per node.
  • Or the app is scaled out horizontally by adding more nodes.
  • The scaling is based on workload, and is independent of the number or scale of the individual databases.

Customize for a tenant

The use of single-tenant databases gives strong tenant isolation. In any app whose model specifies only single-tenant databases, the schema for any one given database can be customized and optimized for its tenant. This customization does not affect other tenants in the app. Perhaps a tenant might need data beyond the basic data fields that all tenants need. Further, the extra data field might need an index.

With database-per-tenant, customizing the schema for one or more individual tenants is straightforward to achieve.

In such a case, a design to carefully manage schema customizations at scale should be taken into consideration.

Comparisons

Measurement Standalone app Database-per-tenant Sharded multi-tenant
Scale Medium
1-100s
Very high
1-100,000s
Unlimited
1-1,000,000s
Tenant isolation Very high High Low; except for any single tenant (that is alone in an MT db).
Database cost per tenant High; is sized for peaks. Low; pools used. Lowest, for small tenants in MT DBs.
Performance monitoring and management Per-tenant only Aggregate + per-tenant Aggregate; although is per-tenant only for singles.
Development complexity Low Low Medium; due to sharding.
Operational complexity Low-High. Individually simple, complex at scale. Low-Medium. Patterns address complexity at scale. Low-High. Individual tenant management is complex.

Services

  1. Auth
    • Handles authentication
  2. Profile
    • Handles user profile
  3. Other Services:
    • Groups : Manage groups which have multiple policies attached to.
    • Policies: Entities with permissions attached to which are attached to groups.
    • Permissions : Granular entities that control access to the tenant.

Schema

  • To update as more items are added

Schema

Technologies

  • Gin
  • PostgreSQL
  • Redis
  • Docker
  • Kubernetes
  • SQLC
  • Golang Migrate

Future Implementation

  • Replace Auth service implementation with an identity provider (Auth0 or Cognito)
  • Expose both REST and gRPC endpoints using gRPC gateway.
  • Re-do the project using Microservice Architecture.
  • Attempt Sharded Multi-tenant approach.

Reference

Multi-tenant SaaS database tenancy patterns

Licence

MIT Licence

go-multitenancy's People

Contributors

shadrackadwera 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.