Question: a process on server not respondingAnswer:1) panic2) take time thinking about underlying cause3) bounce the bastard and pray **
FACT: Answer#3 will often work so well, youoften don’t really spend time to think aboutdoing #2**** FibreError?
Imagine a programming environment: - unlimited process spawning - concurrency someone else’s problem - don’t try to handle errors - let it fail
ErlangBuilt for stability, and not bothering me.Anything else is gravyI wasn’t an erlang programmer
Process isolation- it works so well- nothing shared- has worked so well for so long with OSes- in erlang - each ‘process’ is like a process !
nginx Example: My Host OS haproxy Erlang process supervisor ... p1 p999Each: own heap, garbage collector
Erlang is:- A vm based runtime (light !)- language with prolog heritage (!)- compiler- interpreter- debug tools - batteries included- OTP - an application (server?) platform
Erlang is:- Not OO- no shared state **- state kept in “term stores” - mini DBs- processes easy to hot swap- Quasi functional programming (immutable variables, higher order)- distributed (if you want)
OTP- Open Telecommunications Platform- not about telco !- network stacks/apis, supervisor trees- toolkit for reliable servers (middleware)- behaviours
State in erlangﬁles Host + real kernel Erlang processDETS supervisor ...ETS p1 p999 Send Receive
Erlang processes, like OS processes- Can only send messages to each other- Can fail independently- Can be restarted, safely, independently- Easy to write apps for - Old School !
Better- Tiny overhead (can have 100K+ of them !)- perfect for supervisory agents- distribute: run on every box if you like !- lots of processes == lots of concurrency- if you need to block, block !
Have used erlang for- Supervisory agents - controllers- Autoscaling services (realtime data analytics)- misc backend systems- fun command line tools !- is “lite” VM (startup, footprint)
Supervisor conﬁguration- Declare rules for restarting, failure- So you don’t have to intervene !- can hot reload changes- can have dependent processes
Anyway, that is why we use Erlang, also...- RabbitMQ- Riak (nosql DB)- CouchDB (nosql DB)- Probably your telephone exchange
Alternative approaches:- Use “native” with daemontools/monit etc- Akka (Scala) has similar supervisor- library for your favourite language- ephemeral “state less” apps- Write software without bugs- Or just restart everything 400 times a day
What is not awesome:- OTP boiler plate- VM not as fast as some- No one seems to like the language- tools? IDEs?