Friend is into pigeons, so the only thing that makes sense is to buy a domain with his name and create a PFaaS (Pigeon-Facts-as-a-Service), so that he can flaunt in front of his other, pigeon loving friends
Means of production
Although there are plenty of frameworks that could be used to bootstrap REST
API, Bash shell with nc
was chosen, based on it’s supreme benchmarks
Connections during time – constant output (1) from
nc
, no fluctuations
Netcat is handling the routing, with responses passing through a FIFO pipe
Facts are read from a separate file and fed into an array that is used to show
either a random or a specific fact (/api/fact/{id}
)
After a GET request is parsed (and optional fact ID retrieved), either the target fact or a random one will be JSON marshaled and returned to the client
Obligatory benchmark
Apache Bench shows neat results for one user / one request at a time,
expectedly breaking when either consecutive requests (nc
is not fond of
RFC 2616’s “Connection: close”) or concurrent ones appear
Apache Bench – 1 req
Anything above one (w/o increasing concurrency level)
Pigeon facts to go
Code and a complementary Docker image are available, if you prefer to have it running on-prem
For those that simply want to expand their vast pigeon knowledge, feel free to checkout a random fact on friend’s PFaaS
If you get an error, another user is accessing it, try in a sec