| If you're debugging an Erlang system, you might want to look at Erlang in Anger. [1] As I recall, it's got more information on debugging real systems. Otherwise, the books and references will help you get the syntax and maybe some of the otp system libraries, but the learning part is coming to terms with the core concept of a process as something with a bit of state that reads its message queue and responds. Each process should be fairly simple as it only manages its state and processes one request at a time. Sometimes business requirements make that processing complex. Sometimes processing that request means gathering information from other processes --- this can get complex if there's ordering or consistency requirements; in that case, the least complex option is to make sure all the requests that need consistency among themselves are handled by the same process. If only one process accesses the data and it only processes one message at a time, transactional concerns are easy to manage. ETS works a little different under the hood, but think of each table as a process, if you want to read a key, you send it essentially { self(), read, Key} and it replies with the data. Same deal for writes, etc. Mnesia is processes that you send messages to, and then that process does what you asked and sends the result back. The beauty of an Erlang system is you can get a shell on it, and inspect all sorts of stuff. You can get a list of all the processes, and see how long their message queues are. If something has a long message queue, you can get a copy of the queue and inspect it. If it's a gen_server and it's not totally stuck, you can get a copy of its state. You can look at the ETS tables. You can look at the Mnesia tables. You can look at the ETS or DETS tables underneath the ETS tables. But you do have to be a little careful sometimes. If you are low on memory, and you get a copy of a big message queue, you could exhaust your memory and kill the whole VM. Many of the old footguns have been disarmed, but Erlang still gives you plenty of ammo to shoot yourself in the foot. [1] https://erlang-in-anger.com/ |