Backend Aspects

Popular Stacks

  • Node + ExpressJs
  • Node + Feathersjs
  • Python + Django
  • Python + Flask
  • Java + Spring Boot
  • Elixir + Phoenix

How to decide?

  • Type of API required (REST, WS or Graphql)
  • Type of data (and associated operations)
  • Community Support (Dont choose like Aqueduct - dart server)
  • Cloud support (by AWS, Heroku, Azure, GCP etc)

Authentication Protocols

  • Basic (username:password)
  • JWT Bearer token
  • Oauth 2.0
  • SAML

Which to choose?

  • Client-Server or Server-Server?
  • Token compromise

Storage

  • Tabular data like MySql, Postgres etc.
  • Unstructured data like MongoDb, Firestore etc.
  • Big data or large objects like S3, Azure storage account, Firebase Storage

Database stuffs

  • MySql
  • Postgres
  • MongoDb
  • DynamoDb
  • Firestore

Which to choose?

  • Relational or unstructured data
  • Database Procedures
  • ACID Compliance
  • Support like timeseries, map operations, replication, sharding etc

How to optimise query?

  • Proper indexing
  • Analyse query generated by ORMs
  • Minimize transactions
  • Specify which columns are required in ORMs
  • Try avoiding big queries and joins
  • Use analysing tools like pg_analyse to better optimize your queries
  • Separate out data properly in different tables according to relation between them

Logging - The most underrated player

  • Server logging
  • Services like papertrail, AWS Cloudwatch

What should be logged?

  • Request body, query params and app specific headers
  • Response body, headers and status codes
  • Common stats like origin IP, total response time, request id
  • Other app specific logs like controller logs, services logs etc

General Advice

  • Proper REST Methods Usage
  • Send proper status codes depending upon the operations performed and error response
  • Set proper generic response structure
  • Follow CRUD operations according to HTTP Methods
  • Send verbose error message
  • Paginate large dataset returned
  • Fine tune response data
  • Build flexible endpoints (proper usage of query params, body and headers)
  • Minimise response latency
  • Avoid too much nested response depending on client expectation

Backend Aspects

By Nayan Jyoti Das

Backend Aspects

  • 129