Sequences 2020-12-14 It was the first day of my first Erlang-based system in production. I’ve invested some sensible amount of time to test and stabilize it. I’s were dotted, t’s were crossed and I felt confident that it would work reasonably well. The system broke in production within the first few hours of its life. The breakage was caused by the excessive usage of the ++ operator. I was…
Operating systems via development 2020-06-24 About two years ago I decided to add HTTPS support to this site, using automatic certification via Let’s Encrypt. All the articles on the subject relied on a tool called certbot . A couple of variations were mentioned, some requiring the tool to run while the site is down, others using nginx + certbot combination. It seemed that installing and running…
Periodic jobs in Elixir with Periodic 2020-01-27 One cool thing about BEAM languages is that we can implement periodic jobs without using external tools, such as cron. The implementation of the job can reside in the same project as the rest of the system, and run in the same OS process as the other activities in the system, which can help simplify development, testing, and operations. There are…
Rethinking app env 2018-05-21 What is app env, and what should we use it for? The Elixir docs state : OTP provides an application environment that can be used to configure the application. In my experience, an app env of a moderately complex system will typically contain the following things: Things which are system configuration Things which aren’t system configuration Things which, when modified…
To spawn, or not to spawn? 2017-04-04 That is indeed the question! Whether it is better to keep everything in a single process, or to have a separate process for every piece of state we need to manage? In this post I’ll talk a bit about using and not using processes. I’ll also discuss how to separate complex stateful logic from concerns such as temporal behaviour and cross process communication.…
Reducing the maximum latency of a bound buffer 2016-12-19 Recently I came across two great articles on the Pusher blog: Low latency, large working set, and GHC’s garbage collector: pick two of three and Golang’s Real-time GC in Theory and Practice . The articles tell the story of how Pusher engineers reimplemented their message bus. The first take was done in Haskell. During performance tests they…
Observing low latency in Phoenix with wrk 2016-06-12 Recently there were a couple of questions on Elixir Forum about observed performance of a simple Phoenix based server (see here for example). People reported some unspectacular numbers, such as a throughput of only a few thousand requests per second and a latency in the area of a few tens of milliseconds. While such results are decent, a simple…
Phoenix is modular 2016-02-22 A few days ago I saw this question on #elixir-lang channel: Have any of you had the initial cringe at the number of moving parts Phoenix needs to get you to just “Hello World” ? Coincidentally, on that same day I received a mail where a developer briefly touched on Phoenix: I really like Elixir, but can’t seem to find happiness with Phoenix. Too much magic happening…
Driving Phoenix sockets 2016-01-25 A few months ago, we’ve witnessed Phoenix team establishing 2 millions simultaneous connections on a single server. In the process, they also discovered and removed some bottlenecks. The whole process is documented in this excellent post . This achievement is definitely great, but reading the story begs a question: do we really need a bunch of expensive servers…
Elixir 1.2 and Elixir in Action 2016-01-06 Elixir 1.2 is out , and this is the second minor release since Elixir in Action has been published, so I wanted to discuss some consequences of new releases on the book’s material. Since the book focuses on concurrency and OTP principles, most of its content is still up to date. OTP is at this point pretty stable and not likely to be significantly…
Open-sourcing Erlangelist 2015-11-01 It is a great pleasure to announce that The Erlangelist is now open-sourced . Last week I have made the switch to the completely rewritten, new version of the site, and with this post I’m also making the repository public. Changelog From the end user’s perspective there aren’t many changes: Comments are now powered by Disqus. Some of the past articles are not…
Outside Elixir: running external programs with ports 2015-08-18 Occasionally it might be beneficial to implement some part of the system in something other than Erlang/Elixir. I see at least two reasons for doing this. First, it might happen that a library for some particular functionality is not available, or not as mature as its counterparts in other languages, and creating a proper Elixir…
Optimizing a function with the help of Elixir macros 2015-08-06 Author: Tallak Tveide Today I have a pleasure of hosting a post by Tallak Tveide , who dived into Elixir macros, came back alive, and decided to share his experience with us. This is his story. In this blog post we will cover optimizing an existing function for certain known inputs, using macros. The function that we are going to…
Beyond Task.Async 2015-07-31 In this post I’ll talk about less typical patterns of parallelization with tasks. Arguably, the most common case for tasks is to start some jobs concurrently with Task.async and then collect the results with Task.await . By doing this we might run separate jobs in parallel, and thus perform the total work more efficiently. This can be done very elegantly with…
Speaking at ElixirConf EU 2015-01-26 I’m very excited that my talk on high-availability got accepted for the first European Elixir conference . For the past three years, I have been evangelizing Erlang and Elixir here in Croatia, at our local annual WebCampZg event. In addition, I invested a lot of effort writing the book on Elixir which is now in its final stages. All this work has been motivated…
Conway's Game of Life in Elixir 2014-11-24 About a month ago, on Elixir Quiz site there was a Conway’s Game of Life challenge . While I didn’t find the time to participate in the challenge, I played with the problem recently, and found it very interesting. So in this post, I’m going to break down my solution to the problem . If you’re not familiar with Game of Life rules, you can take a quick look…
Understanding Elixir Macros, Part 6 - In-place Code Generation 2014-07-06 Today’s post is the last one in the macro series. Before starting, I’d like to extend kudos to Björn Rochel who already improved on deftraceable macro in his Apex library. Björn discovered that the blog version of deftraceable doesn’t handle default args ( arg \\ def_value ) properly, and implemented a fix . In the meantime,…
Understanding Elixir Macros, Part 5 - Reshaping the AST 2014-06-29 Last time I presented a basic version of deftraceable macro that allows us to write traceable functions. The final version of the macro has some remaining issues, and today we’ll tackle one of those - arguments pattern matching. Today’s exercise should demonstrate that we have to carefully consider our assumptions about possible…
Understanding Elixir Macros, Part 4 - Diving Deeper 2014-06-23 In previous installment , I’ve shown you some basic ways of analyzing input AST and doing something about it. Today we’ll take a look at some more involved AST transformations. This will mostly be a rehash of already explained techniques. The aim is to show that it’s not very hard to go deeper into the AST, though the resulting code…
Understanding Elixir Macros, Part 3 - Getting into the AST 2014-06-15 It’s time to continue our exploration of Elixir macros. Last time I’ve covered some essential theory, and today, I’ll step into a less documented territory, and discuss some details on Elixir AST. Tracing function calls So far you have seen only basic macros that take input AST fragments and combine them together, sprinkling…
Understanding Elixir Macros, Part 2 - Micro Theory 2014-06-11 This is the second part of the mini-series on Elixir macros. Last time I discussed compilation phases and Elixir AST, finishing with a basic example of the trace macro. Today, I’ll provide a bit more details on macro mechanics. This is going to involve repeating some of the stuff mentioned last time, but I think it’s beneficial to…
Understanding Elixir Macros, Part 1 - Basics 2014-06-06 This is the first article in the miniseries that deals with macros. I originally planned on treating this topic in my upcoming Elixir in Action book, but decided against it because the subject somehow doesn’t fit into the main theme of the book that is more focused on the underlying VM and crucial parts of OTP. Instead, I decided to provide a…
Why Elixir 2014-01-21 It’s been about a year since I’ve started using Elixir. Originally, I intended to use the language only for blogging purposes, thinking it could help me better illustrate benefits of Erlang Virtual Machine (EVM). However, I was immediately fascinated with what the language brings to the table, and very quickly introduced it to the Erlang based production system I have been…