MCQs on Distributed Systems in Elixir | Elixir

Elixir’s ability to build fault-tolerant, distributed systems is one of its strongest features, utilizing the Erlang VM for seamless node communication, clustering, and fault tolerance. Understanding how to set up and manage distributed Elixir nodes, perform Remote Procedure Calls (RPC), and handle failures is crucial for building resilient applications. These 30 multiple-choice questions (MCQs) will help you dive deep into distributed systems concepts in Elixir programming.


MCQs on Distributed Systems in Elixir

Setting up Distributed Elixir Nodes

  1. What command is used to start an Elixir node?
    • a) elixir --sname <name>
    • b) iex --name <name>
    • c) elixir --name <name>
    • d) iex --sname <name>
  2. How do you connect two Elixir nodes together?
    • a) By using Node.connect/1
    • b) By using Node.link/1
    • c) By using Node.connect/2
    • d) By using Node.join/1
  3. What does the --sname option in the iex command specify?
    • a) The short name of the node
    • b) The node’s IP address
    • c) The long name of the node
    • d) The node’s cluster type
  4. Which command starts an Elixir node with a specific cookie for authentication?
    • a) iex --cookie <cookie_name>
    • b) elixir --cookie <cookie_name>
    • c) iex --name <name> --cookie <cookie_name>
    • d) elixir --name <name> --cookie <cookie_name>
  5. What is the default cookie used when starting an Elixir node?
    • a) 1234
    • b) secret
    • c) abc123
    • d) No default cookie
  6. How do you check if an Elixir node is connected to another node?
    • a) By using Node.alive?/1
    • b) By using Node.connect?/1
    • c) By using Node.status/1
    • d) By using Node.ping/1
  7. What does the Node.list/0 function return?
    • a) A list of connected nodes
    • b) A list of nodes in the cluster
    • c) A list of all active processes
    • d) A list of available resources
  8. What is the function used to stop an Elixir node?
    • a) Node.exit/1
    • b) Node.stop/0
    • c) Node.shutdown/0
    • d) Node.disconnect/1

Node Communication and Clustering

  1. Which command can you use to see the status of all nodes in a cluster?
    • a) Node.status/0
    • b) Node.list/0
    • c) Node.cluster/0
    • d) Node.info/0
  2. What is the primary communication protocol between nodes in a distributed Elixir system?
  • a) TCP/IP
  • b) HTTP
  • c) Erlang’s distribution protocol
  • d) WebSocket
  1. Which of the following is necessary for two Elixir nodes to communicate with each other?
  • a) The nodes must be in the same local network
  • b) The nodes must share the same cookie
  • c) The nodes must be running the same version of Erlang
  • d) All of the above
  1. How can a node in a distributed system join a cluster?
  • a) By using Node.join/1
  • b) By using Node.connect/1
  • c) By using Node.link/1
  • d) By using Node.add_to_cluster/1
  1. Which function in Elixir allows for sending a message from one node to another?
  • a) send/2
  • b) Node.send/2
  • c) Node.call/2
  • d) GenServer.call/2
  1. How can you monitor the connections between nodes in an Elixir cluster?
  • a) By using Node.monitor/1
  • b) By using Node.link/1
  • c) By using Process.monitor/1
  • d) By using Node.connect/1
  1. What happens when a node is disconnected from a cluster in Elixir?
  • a) The node crashes immediately
  • b) The node continues running without any issues
  • c) The node may lose its state if not properly handled
  • d) The node automatically re-connects to the cluster
  1. How can a node leave a cluster in Elixir?
  • a) By using Node.leave/1
  • b) By using Node.stop/0
  • c) By using Node.disconnect/1
  • d) By using Node.exit/0

RPC in Distributed Systems

  1. What does RPC stand for in the context of Elixir?
  • a) Remote Procedure Call
  • b) Remote Parallel Computing
  • c) Reliable Process Communication
  • d) Runtime Process Control
  1. How do you call a function on a remote node in Elixir?
  • a) By using Node.call/2
  • b) By using GenServer.call/2
  • c) By using RPC.call/2
  • d) By using Node.spawn/1
  1. Which function is used to perform an RPC call in Elixir?
  • a) Node.call/2
  • b) Node.spawn/1
  • c) GenServer.cast/2
  • d) GenServer.call/2
  1. What happens when an RPC call is made to a non-existing process on a remote node?
  • a) The node crashes
  • b) A timeout error is raised
  • c) The call is ignored
  • d) The process is spawned automatically
  1. What is the function used to send an asynchronous RPC request in Elixir?
  • a) Node.async/2
  • b) Node.call/2
  • c) GenServer.cast/2
  • d) Node.spawn/2
  1. How do you ensure that an RPC call is routed to the correct node?
  • a) By using the node name and process name
  • b) By using the IP address of the node
  • c) By using the node’s cookie for authentication
  • d) By using the process ID (PID) of the remote process
  1. Can you use RPC calls to communicate with a remote process that is inside a GenServer on another node?
  • a) Yes, you can use GenServer.call/2
  • b) No, only local processes can be called via RPC
  • c) Yes, by using Node.spawn/1
  • d) Yes, but only if both nodes share the same cookie
  1. What function can be used to manage timeouts in an RPC call?
  • a) GenServer.call/2 with a timeout option
  • b) Node.call/2 with a timeout option
  • c) Node.spawn/1 with a timeout option
  • d) Process.call/2 with a timeout option

Fault Tolerance in Distributed Systems

  1. Which Elixir feature ensures that a node can continue running even when other nodes fail?
  • a) Supervisor trees
  • b) Process pools
  • c) Task supervision
  • d) GenServer retries
  1. How does Elixir handle process crashes in a distributed system?
  • a) By automatically restarting the process
  • b) By logging the error and continuing
  • c) By sending a termination signal
  • d) By crashing the entire node
  1. What is the purpose of :net_adm.ping/1 in Elixir?
  • a) To check if a node is reachable over the network
  • b) To ping a process inside a node
  • c) To monitor a node’s state
  • d) To test the system’s network performance
  1. Which Elixir feature helps manage the failure of one node in a cluster?
  • a) Supervisor strategy
  • b) Task pool
  • c) Connection pool
  • d) Event-based retry mechanism
  1. How can you monitor the health of nodes in a distributed system?
  • a) By using Node.monitor/1
  • b) By using Process.monitor/1
  • c) By using GenServer.monitor/1
  • d) By using Node.list/0
  1. What happens when a node crashes in a distributed Elixir system with a supervisor?
  • a) The supervisor restarts the crashed node
  • b) The supervisor restarts the crashed process
  • c) The supervisor reports the crash but does not take action
  • d) The supervisor kills the other nodes in the cluster

Answers:

QnoAnswer
1c) elixir --name <name>
2a) By using Node.connect/1
3a) The short name of the node
4c) iex --name <name> --cookie <cookie_name>
5d) No default cookie
6a) By using Node.alive?/1
7a) A list of connected nodes
8b) Node.stop/0
9b) Node.list/0
10c) Erlang’s distribution protocol
11d) All of the above
12a) By using Node.join/1
13a) send/2
14b) By using Node.link/1
15c) The node may lose its state if not properly handled
16a) By using Node.leave/1
17a) Remote Procedure Call
18a) By using Node.call/2
19a) Node.call/2
20b) A timeout error is raised
21a) Node.async/2
22a) By using the node name and process name
23a) Yes, you can use GenServer.call/2
24b) Node.call/2 with a timeout option
25a) Supervisor trees
26a) By automatically restarting the process
27a) To check if a node is reachable over the network
28a) Supervisor strategy
29a) By using Node.monitor/1
30b) The supervisor restarts the crashed process

Use a Blank Sheet, Note your Answers and Finally tally with our answer at last. Give Yourself Score.

X
error: Content is protected !!
Scroll to Top