Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/1602/request-scaled

Request wrapper with scaling capabilities (dns lookup, ip address selection)
https://github.com/1602/request-scaled

Last synced: about 1 month ago
JSON representation

Request wrapper with scaling capabilities (dns lookup, ip address selection)

Awesome Lists containing this project

README

        

# Request scaled

The `request-scaled` is a wrapper around `request` to work with scaled services, for example multiple instances of docker container.

## Motivation

Normally if you want to scale you should use load balancer such as nginx or haproxy,
autogenerate config file for your balancer based of infrastructure changes. In other words amount of accidental complexity it requires to add is big enough to not even think of scaling at quick prototyping stage.

But what if we could avoid this accidental complexity and only do what is essential for scaling of http server: sending requests to different instances of service.

All we have to do then is to perform dns lookup, pick random ip and use it instead of host, this is exactly and the only thing this library does.

## Usage

```
const request = require('request');
const requestScaled = require('request-scaled')(request);

// use requestScaled as you would use request
requestScaled.get('http://api:3000/perform/heavy/query')
.then(res => {
// res is http response
})
.catch(err => {
// handle error
console.error('Error from api:3000/perform/heavy/query', err);
});
```

## Control over DNS lookup

no control yet, maybe coming soon

## LICENSE

[MIT](./LICENSE)