Application architecture
Patterns, practices, and suggestions.
Fast key:value storage
- Prototyping: Use
new Map()for fast in-memory key:value storage - Small/Medium scale: Use a local (Docker)
Redis casefor fast and free storage - High scale: Use a cloud version
Azure Redis caseorAWS ElistiCache
When to throttle
Throttling limits how often a function can run, regardless of how often it is called.
Examples of when to throttle are:
- Scroll position updates
- Infinite scrolling
- Tracking mouse movement
- Resizing a window while updating a layout
- Anything where you want continuous but controlled execution
When to debounce
Runs a function only after the event has been quiet for a set period.
Examples of when to debounce are:
- Search-as-you-type (wait until typing stops)
- Auto-saving form data
- Validating input
- Resizing a window and doing something after the resize ends
- Anything where you want the final, settled actio
Scaling
Things to consider, when wishing to improve scale.
Horizontal scaling
Recreating multiple instances of your services.
Load balancing
To distribute traffic to you services, you require a load balancer which will distribute traffic according to the load on your services.
DB Sharding
The database is a single point of failure and also a performance bottleneck. Database sharding is partitioning your database across multiple databases.
Caching
Latency is a factor, so implementation of caching will reduce this. Cache is a temporary memory of data for similar requests.
Queues
Too many requests are then hitting your system, so queues can buffer requests as they come in.
Content Delivery Networks (CDN)
Static content is then put on a CDN which is closest to the user, hence loading fast.