Suicidal tendencies in show business

Yours Truly, Jack of all trades, master of some.

Сила воли

Или как выйти из рекурсивного запоя.

Суицидальные наклонности в шоу-бизнесе

или "Cмерть актёра - это ещё не занавес"

This talk is not about Elixir.

Albeit it could be related.

It's not solemn, but it is not bereft of seriousness.

I'm not the drone you're looking for

  1. I don't use Elixir (much) (yet)

Name's Dima. Pleasure to meet you.

Baby steps

			
def run
	unless ENV['DEBUG']
		Process.daemon true # don't chdir for now
		Process.setsid # We're the session and group leader now
	end
	write_pid
	trap_term_signal
	begin
		run_master_loop
			
		

Baby steps

			
def run_master_loop
	tick_interval = 1
	until @stop
		if Master::DESIRED_RUNNERS > Display.emitted_displays_total
			Watchdog.spawn_runner
		end
		Watchdog.check_displays
		sleep tick_interval
	end
end
			
		

Fire and forget

The core practical nuance behind actors.

As I later learned

Fire and forget

I don't care how succsessful any particular process/thread of execution is as long as I get desired result.

I can't affort babysitting a bunch of whiny kids.

Fire and forget

			
try {
    c = Cipher.getInstance("AES/CBC/PKCS7PADDING");
    c.init(Cipher.DECRYPT_MODE, key, iv);
    result = c.doFinal(data);
} catch (NoSuchAlgorithmException | NoSuchPaddingException | BadPaddingException | IllegalBlockSizeException | InvalidAlgorithmParameterException | InvalidKeyException e) {
    e.printStackTrace();
}
			
		

Forget me not

There is a threshold of noticeability.

If 90% of the processes die without executing main code, I'm wasting money.

You think herding cats is hard? Try herding bunch of processes on a resource starved kernel. I got to learn tweaks no one should ever learn.

All is good that ends good

Don't worry, I've forgotten them all.

Actors

The actor model in computer science is a mathematical model of concurrent computation that treats "actors" as the universal primitives of concurrent computation. In response to a message that it receives, an actor can: make local decisions, create more actors, send more messages, and determine how to respond to the next message received. Actors may modify private state, but can only affect each other through messages (avoiding the need for any locks).

Actor model is a lot more than I'm talking about.

Actors in wikipedia

The Actor model adopts the philosophy that everything is an actor.

An actor is a computational entity that, in response to a message it receives, can concurrently:

I smell OOP spirit. Well, Smalltalk was an inspiration.

Meet Celluloid

https://celluloid.io/

An actor model library for Ruby. Mimics Erlang and Akka (which too mimics Erlang).

Used in Sidekiq up till last year. I've used it successfully for a bunch of long running daemons. A lifesaver for any kind of task, that can be reduced to a set of isolated execution units.

Meet Elixir

http://elixir-lang.org/

Erlang VM with GMO.

Other speakers have introduced it to you.

Processes in BEAM are isolated, easy to create, easy to forget when need be.

Meet Elixir

Tell your fellow system administrator that they can have great syntax with Erlang VM.

They'll curse and praise you while rewriting their custom tools.

Biblical ending

Hopefully the one without stoning.

Thank you

I hope this was entertaining and educating.