Akka Flashcards

1
Q

Akka is made up of

A

Modules that are distributed as JAR files

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does the Akka concept of ‘let it crash?’ anticipate

A

There will be cases of individual handlers failing to carry out their tasks, and it is prepared to reroute that work to avoid a catastrophic failure.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What happens if the failure occurs up the chain?

A

Underlings can carry on until a new supervisor arrives. There is no broken chain, and most importantly, it is no longer the duty of the developer to find all the ways that chain might break catastrophically and provide specialized handling for each case

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Actors are lightweight because

A

They run on top of dispatchers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How many threads fit in 1GB of memory and how many actors

A

4096

2.7 Million

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you get an actor reference to an actor in the hierarchy?

A

You use the actor path

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

actors are a lot like ___________ without the configuration and ________ ________
installation overhead

A

message queues

message broker

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Messages are simple data structures that …

A

can’t be changed after they’ve been created,

or in a single word, they’re immutable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Actors can receive messages one at a time and execute some behaviour whenever a
message is received. Unlike queues, they can

A

also send messages

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the points made in the reactive manifesto

A

 Blocking I/O limits opportunities for parallelism, so nonblocking I/O is preferred.
 Synchronous interaction limits opportunities for parallelism, so asynchronous interaction is preferred.
 Polling reduces opportunity to use fewer resources, so an event-driven style is preferred.
 If one node can bring down all other nodes, that’s a waste of resources. So you need isolation of errors (resilience) to avoid losing all your work.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What two goals should we aim for in attempting to make applications scalable?

A

Complexity must stay as low as possible.

Resources must be used as efficiently as possible while you scale the application

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Scaling out with ____ and scaling up with ____ are not good ideas

A

RPC

Low level threading

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Why is scaling out with RPC not a good idea?

A

Every RPC call needs to bloc the current thread and wait for a response from the network. Impeded the goal of using resources efficiently.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Why is using a combination of RPC and threading not a good idea?

A

You need to know exactly where you scale up or scale out. (Increase in complexity)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Spinning up thousands of servers is simple today, but

A

the same cannot be said for programming them

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Actors are nothing new at all, in and of themselves. It’s … that make them unique

A

It is the way that actors are provided in Akka to scale applications both up and out on the JVM

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

This type of database is often called a journal

A

when changes are kept as a sequence of events

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

The technique of storing changes as a sequence of events is called

A

event sourcing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

How can event sourcing be kept consistent across two servers?

A

sharding or partitioning

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Most general purpose programming languages are written in sequence. A ________ ______ ____ is required to bridge the gap between sequential definition and parallel execution

A

concurrent programming model

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Whereas parallelization is all about executing processes simultaneously, concurrency concerns itself with

A

defining processes that can function simultaneously, or can overlap in time, but don’t necessarily need to run simultaneously.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

An actor is a lightweight process that has only four core operations:

A

create, send, become, and supervise

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Any actor can be a supervisor but

A

only for actors that it creates itself

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

How are actors decoupled?

A

on three axes - namely

  • Space / location
  • Time
  • Interface
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

What happens when an actor is decoupled in space

A

An actor gives no guarantee and has no expectation about where another actor is located

26
Q

What happens when an actor is decoupled in time

A

An actor gives no guarantee and has no expectation about when its work will be done

27
Q

What happens when an actor is decoupled from interface - that is it has no defined interface

A

The actor has no expectation about which messages other components can understand.

28
Q

The first thing that every Akka application does is …

A

Create the Actor System

29
Q

Which actors can the actor system create

A

The so called top-level actors

30
Q

The actor system can create so called top-level actors, and it’s a common pattern to

A

Create only one top-level actor for all actors in the application. The Supervisor actor that monitors everything

31
Q

An ActorSystem returns an address to create the top-level actor instead of the actor itself. This is called an

A

ActorRef

32
Q

An ActorSystem returns an address to the created top-level actor instead of the actor itself. This address is called an ActorRef. The ActorRef can be used to send messages to the actor. This makes sense when you think about the fact that

A

the actor could be on another server

33
Q

Sometimes you would like to look up an actor in the actor system this is where _____ _____ come in.

A

Actor Paths come in

34
Q

You could compare the hierarchy of actors to a URL path structure. Every actor has a name. This name needs to be …

A

unique per level in the hierarchy: two sibling actors can’t have the same name

35
Q

All actor references can be located directly by

A

an actor path (absolute or relative)

36
Q

What does a dispatcher do?

A

pushes the messages in the mailbox through the actors

37
Q

The type of dispatcher determines …

A

which threading model is used to push the messages through

38
Q

All kinds of dispatchers can be configured in some way, and you can allocate a dispatcher to an

A
  • actor
  • a specific group of actors
  • all of the actors in a system
39
Q

When you send a message to an actor, all you are really doing is

A

leaving a message behind in its mailbox. Eventually a dispatcher will push it through the actor

40
Q

Per the REST conventions, a GET whose URL ends with an entity type should return

A

a list of known instances of that entity

41
Q

Why is
implicit val ec = system.dispatcher
needed in order to call
Http().bindAndHandle

A

bindAndHandle is asynchronous and requires an implicit ExecutionContext

42
Q

what happens after

implicit val system = ActorSystem()

A

the actor system is immediately available

43
Q

When you define an implicit val with execution context it does what?

A

determines which execution context will be used by Future(s) in scope of its definition

44
Q

Dispatchers implement the ExecutionContext interface and can thus be

A

used to run Future invocations etc.

45
Q

an asynchronous method returns a ______ before it is completed

A

future

46
Q

How would you program an actor to respond to a message assuming there were three types of message namely Larry, Curly and Mo

A
def receive = {
    case Larry(punch) => 
    case Curly() =>
    case Mo(something) =>
      }
47
Q

actors created with the context of another actor are

A

its children and subject to the parent actor’s supervision

48
Q

what does

Http().bindAndHandle(api, host, port) do?

A
binds the routes defined in
the RestApi (api) to the HTTP server
It is asynchronous so it returns a 'future' before it is completed
49
Q

Services interfaces, as they grow, need

A

more sophisticated routing of requests

50
Q

Actors exist in a supervision hierarchy - what does this mean

A

each actor has a supervisor and can have one or several child actors for which it is responsible

51
Q

An actor can send and receive messages of any kind using the _______ method

A

receive

52
Q

An actor can send and receive messages of any kind using the receive method, which is a so-called partial function that uses …

A

Scala’s pattern matching to figure out which case statement will deal with the incoming message.

53
Q

What is a partial function?

A

A partial function is a function that does not provide an answer for every possible input value it can be given

54
Q

Since the ’90s, nothing much has changed in how programming languages support networking, either.
Many technologies still essentially use ____________ to communicate over the network

A

RPC (remote procedure calls)

55
Q

One doomsday scenario is where you’d need to pay increasingly more for more underutilized resources. Another nightmare scenario is

A

where the complexity of the application shoots through the roof when more resources are added.

56
Q

Spinning up thousands of servers is simple today, but

A

the same cannot be said for programming them

57
Q

It shouldn’t matter if we send a message locally on one server or remotely to another. So we need _______________________________ It will also need to ________________________________. This is
one of the things that _______ does for you.

A
  1. some service that takes care of sending the messages to actors on other servers if necessary.
  2. It will also need to keep track of where actors live and be able to provide references so other servers can communicate with the actors.
  3. Akka
58
Q

This is the biggest impediment to building applications that can recover from failure and scale according to demand.

A

Coupling components in location, time, and interface is the biggest impediment to building applications that can recover from failure and scale according to demand.

59
Q

The messages that an actor can receive or send back on a request are bundled together in

A

the actors’ companion object

60
Q

If an actor is created using the system - as in

createBoxOffice = system.actorOf(BoxOffice.props, BoxOffice.name) how are the child actors created?

A

Using their context

CreateTicketSeller = context.actorOf(TicketSeller.props(name), name)

61
Q

What does a materializer do?

A

makes actors execute a graph to produce results

62
Q

A graph, in its simplest form, consists of

A

a source that provides elements, and a sink that consumes elements.