Solution design in Java/OOP vs. Clojure/FP - I/O anywhere or at the boundaries? - experience

As a Clojure developer thrown into an “enterprise” Java/Spring/Groovy application, I have a unique opportunity to experience and think about the differences between functional (FP) and object-oriented programming (OOP) and approach to design. Today I want to compare how the solution would differ for a small subsystem responsible for checking for and progressing the process of fixing data discrepancies. The main question we will explore will be where do we deal with external effects, i.e. I/O.

(We are going to explore here an application of the Functional Core, Imperative Shell architecture. You can learn more about it in the Related resources section.)

Continue reading →

It will only take one hour… (On why programmers suck at estimating and the perils of software development)

“It will only take about an hour,” I said to her. Two days later, a pull request awaits review. Where has all that time gone? What are the sources of delay in software development and how can we make it faster?

Continue reading →

Java/Spring App Troubleshooting on Steroids with Clojure REPL

(Published originally at the Telia Engineering blog.)

We have a Java/Groovy Spring Boot webapp, mainly running a bunch of batch jobs fetching, transforming and combining data. It is challenging to troubleshoot production issues because some production APIs are only accessible from the production servers and it is difficult and possibly dangerous to run the application in full production setup locally. Fortunately, we can now connect a REPL to the running application, get hold of its Spring beans, and interact with it (invoking remote calls, checking the returned data, …), which is a real life-saver and something I want to demonstrate and describe here.

Continue reading →

How to use Clojure 1.10 pREPL to connect to a remote server (WIP)

Clojure 1.10 includes a new, program-friendly REPL or prepl (pronounced as “preppy,” not p-repl). However there is still very little documentation about it, though it is reportedly in making (it is alpha, after all). Here I want to demonstrate how to start it and how to connect to it in a primitive way (I hope to improve the user experience of the client eventually).

Update 22/3: Check out O. Caldwell’s Clojure socket prepl cookbook.

Continue reading →

AWS RDS: How to find out login credentials to the database

To log in to your AWS RDS database (Oracle in my case) you need login credentials, but what are these for a newly created DB? The password is the master user password you entered during DB creation and which you can change via the Console.

To find out the master user name:

Continue reading →

Migrating from to a static site generated by GatsbyJS

I am moving my blog over from to a statically generated site using Gatsby. Wordpress has served me well in many years but it isn’t really fit for writing (about) code and the latest updates have made it even more difficult for me. With Gatsby I get a quick site and full control over everything (using JavaScript, React, and any of the tons of plugins for Gatsby).

The content from my old blog is coming soon, it is work in progress :-)

Continue reading →

Java: Simulating various connection problems with Toxiproxy

Java: Simulating various connection problems with Toxiproxy

Simulate various connection issues with Toxiproxy and Java's HttpURLConnection to see what kind of errors get produced: connect timed out vs. read timed out vs. connection refused ... .


System: openjdk 11.0.1 2018-10-16

  1. (.setConnectTimeout 1) => connect timed out
  2. (.setReadTimeout 1) => Read timed out on HTTPS, Read timed out on HTTP (or Toxiproxy with 5s latency or timeout )
  3. Nothing listening at the port => Connection refused
  4. Toxiproxy with no upstream configured (i.e. the port is open, but nothing happesn with the connection) => Remote host terminated the handshake on HTTPS, Read timed out on HTTP
  5. limit_data_downstream => Premature EOF

(What I haven't been able to simulate (yet) is "connection interrupted/broken", i.e. Connection reset (perhaps you closed it and try to write to it anyway?) and Connection reset by peer (perhaps when dropped by a firewall/the server/...?).)

The setup


To /etc/hosts add:

The toxiproxy setup

Start toxiproxy:

docker pull shopify/toxiproxy
# BEFORE we `run` it: case #3
docker run --rm -p 5555:5555 -p 6666:6666 -p 8474:8474 --name toxiproxy -it shopify/toxiproxy

Configure it (we could just POST to :8474 but using the CLI is easier):

$ docker exec -it toxiproxy /bin/sh
/ # cd /go/bin/
# ./toxiproxy-cli create google -l -u # BEFORE this is run: case #4
# ./toxiproxy-cli toxic add google -t latency -a latency=5000 # case #2
Added downstream latency toxic 'latency_downstream' on proxy 'google
# ./toxiproxy-cli toxic remove google -n latency_downstream
Removed toxic 'latency_downstream' on proxy 'google'

# ./toxiproxy-cli toxic add google -t  timeout -a timeout=2000 # case #2
Added downstream timeout toxic 'timeout_downstream' on proxy 'google'
# ./toxiproxy-cli toxic remove google -n timeout_downstream
Removed toxic 'timeout_downstream' on proxy 'google'

# ./toxiproxy-cli toxic add google -t limit_data -a bytes=5000 # case #5
Added downstream limit_data toxic 'limit_data_downstream' on proxy 'google'

The test code

(import '[ URL HttpURLConnection])
  (doto ^HttpURLConnection (.openConnection (URL. ""))
    ;; BEWARE: JVM *must* be started with `` to allow setting the Host:
    (.setRequestProperty "Host" "")
    (.setConnectTimeout 1000)
    (.setReadTimeout 1000))


Read my Simulating network timeouts with toxiproxy to learn why we need to bother with /etc/hosts and the Host header.

view hosted with ❤ by GitHub

Continue reading →

Clojure - comparison of gnuplot, Incanter, oz/vega-lite for plotting usage data

What is the best way to plot memory and CPU usage data (mainly) in Clojure? I will compare gnuplot, Incanter with JFreeChart, and vega-lite (via Oz). (Spoiler: I like Oz/vega-lite most but still use Incanter to prepare the data.)

The data looks like this:

;; sec.ns | memory | CPU %
1541052937.882172509 59m 0.0
1541052981.122419892 78m 58.0
1541052981.625876498 199m 85.9
1541053011.489811184 1.2g 101.8

The data has been produced by

The tools

Gnuplot 5

Gnuplot is the simplest, with a lot available out of the box. But it is also somewhat archaic and little flexible.

Continue reading →

How I got fired and learned the importance of communication and play time

When I came to the office one late autumn morning in 2005, I have been shocked to find out that - without any warning signs whatsoever - I hd been fired. That day I have learned the importance of communication. Their criticism was justified but the thing is, nobody bothered to tell me anything during my 11 months in the company. I received exactly 0 feedback about my behaviour or work. The company ended up at court with its client - which both explains why they were stressed and was also caused by bad communication. So communication - even, or especially under stress - is really important. It must be open, transparent, and broad.

The funny thing is that I still do the things they fired me for.

Continue reading →

Beware the performance cost of async_hooks (Node 8)

I was excited about async_hooks
Continue reading →

How good monitoring saved our ass ... again

You know how it goes - suddenly people complain your app does not work, your are getting plenty of timeouts or other errors in your error tracking tool, you find the backend app that is misbehaving and finally "fix" the problem by restarting it. Phew!

Continue reading →

Monitoring process memory/CPU usage with top and plotting it with gnuplot


If you want to monitor the memory and CPU usage of a particular Linux process for a few minutes, perhaps during a performance test, you can capture the data with top and plot them with gnuplot. Here is how:

Continue reading →

Troubleshooting Received fatal alert: handshake_failure

Re-published from the Telia Tech Blog.

Continue reading →

Experience Report: Hiring for Clojure(Script) is Easy

Published originally at the Telia Engineering blog.

Update Jan 2020: Added "Related resources and experiences".

Continue reading →

Pains with Terraform (perhaps use Sceptre next time?)

Cross-posted from Telia's Tech Blog

We use Amazon Web Services (AWS) heavily and are in the process of migrating towards infrastructure-as-code, i.e. creating a textual description of the desired infrastructure in a Domain-Specific Language and letting the tool create and update the infrastructure.

We are lucky enough to have some of the leading Terraform experts in our organisation so they lay out the path and we follow it. We are at an initial stage and everything is thus "work in progress" and far from perfect, therefore it is important to judge leniently. Yet I think I have gain enough experience trying to apply Terraform both now and in the past to speak about some of the (current?) limitations and disadvantages and to consider alternatives.

Continue reading →

Copyright © 2021 Jakub Holý
Powered by Cryogen
Theme by KingMob