* editing post for lewdlad and adding s1ck diagram of architecture

This commit is contained in:
shockrah
2021-07-17 11:55:14 -07:00
parent fbe4781890
commit 5bfe5994b1
3 changed files with 485 additions and 14 deletions

30
posts/eco-eats.md Normal file
View File

@@ -0,0 +1,30 @@
# Economical Eats
## A dense packing of information those in recently found hard times
It's official: your _broke and need help, but food is expensive and you're starving, what do you do?_ Let me show you.
## Precursor
* These tips are general purpose and can be changed to fit your needs
* The target audience is anyone who hasn't been _broke_
* These tips are to arm you with the knowledge to survive in modern circumstances
## Good Wholesome Tips
## Ugly Tips
## Blackpill
> These are absolute last resort and if you find yourself here either you fucked up or still have a chance to fix something else
> Nearly all of the following tips are demonstrably awful for you in some way
## More resources
Here's a bunch of links
## Afterthoughts
todo

View File

@@ -2,29 +2,29 @@
## What is "Lewdlad"
Lewdlad is a Discord chat bot I created which (at the time of writing this) is used to orchestrate multiple AWS EC2 servers to provide affordable game servers to various communities that I help run.
Lewdlad is a Discord chat bot I created which (at the time of writing this) is used to orchestrate multiple AWS EC2 servers which run different game servers(Minecraft, Reflex, Hexxit, etc).
### Some history
The very first version of Lewdlad was a python script that would literally pick random images from a set of red boards on 4chan and send it to a random online person in the guild.
Eventually I created a bot(that had 1 command), that would invoke this script and send the results to whoever invoked the command.
That command is `.roll`.
After some time I added some more 4chan related commands and eventually _the Hanime module_.
The first version of Lewdlad was a Python script that would literally pick random images from a set of red boards on 4chan and send it to a random person.
Eventually I turned it into a bot which basically just sent the random image to whoever invoked the command.
The Hanime module is weird because it was conceived out of a joke: "what if Lewdlad recommended some fire hentai".
Being that it was likely 2 AM and I was bored I did some searching and found that there is no public API for Hanime.
I then opened up the site and did some reverse engineering to figure out how to spoof a browser request and get some results.
Some reversing and trial-and-error later and I had a working request script, and could search.
Finally I took this script, wrapped with some ergonomics and hooked it into the Lewdlad's codebase.
After some time came the _Hanime_ module, which came from a joke of "I wish Lewdlad would send some fire hentai.
After some research I realized querying the site wasn't going to be easy since there wasn't a public nice made API.
To this end I opened up the site and did some reverse engineering to figure out how to spoof a browser request and get some results.
Some reversing and trial-and-error later and I had a working request script which I could hook up to the bot.
Slapped it all behind a command with some basic arguments and like `.pron` was born.
### The beginnings of orchestration
### The beginnings of the server manager
Around this time I started hosting a minecraft server for friends to play on.
Being that the server had limited _burst capacity_ I knew I had to make sure the server could replenish its burst for when the _peak hours_ hit.
To achieve this I put Lewdlad on the same server as the minecraft game files and put the `start-minecraft.sh` script behind a command for Lewdlad to use.
Being hosted on AWS meant the server had _burst capacity_, which basically means the CPU can boost temporarily to handle harder workloads.
This ability is similar to a magic ability in most games, takes up some MP and has to recharge.
While idling a vanilla minecraft server sits very close to the _burst limit_ where the CPU starts using its _burst capability_.
To make sure it didn't needlessly burst I put Lewdlad on the same server as the minecraft game files and put a `start-minecraft.sh` script behind a command for the bot to use.
The architecture was surprisingly simple and ended up being way more flexible and easy to use than I ever expected.
Basically each game had its own directory in a predetermined directory:
I ended up extending it to this with multiple games so each game had its own directory in a predetermined directory:
```
Lewdlad/
@@ -61,4 +61,36 @@ This meant a minimal configuration could look like
Adding crash safety is trivially easy as recovering is a matter of checking configuration files and determining which are _falsely active_.
## A new Architecture
The new architecture has a few goals in mind:
* Reduce operating costs
* Reduce impact of game failure
* learned the hard way how bad wine would throttle everything
* More flexibility
![](/media/img/lewdlad/arch.svg)
The text version of this goes like this:
* Lewdlad lives on its own virtual private server
* Each game server is now its own EC2 instance
* Basically just an EC2 cluster
* Loggerlad is whatever I decide to use for centralized logging
### Pros
* Only get charged for ec2 instances that are _actually live/running_
* Elastic IP's are cheap as hell per month
* Lots of free logging services that I could technically even host my self.