A Company’s Story Crystallized: Linkfeed

Kostya Makarchev is the CTO of Linkfeed, a Russian company that focuses on search engine optimization (SEO).

Ivo:

What production projects do you use Crystal for?

Kostya Makarchev:

In our company, I rewrote a backend API from Ruby (event-machine) to Crystal (21 shards, 300KB source size, compiled size 21MB). This backend has a high load throughput, using Redis and the network. The Ruby version had many concurrency and stability problems (crashed from time to time, slow, had bugs that were hard to debug, nil exceptions). Also, it used a lot of network communications, which we handled with threads or by event-machine, which in Ruby is quite bad.

The Crystal version has now been in production for over a year, and it is much more stable and faster than the Ruby app: it works without any problems. It comprises an HTTP server, Redis, network connections, HTTP fetching, and an HTML parsing application, all with many concurrency aspects, and running as some 20 background processes.

Ivo:

Why did you decide to use Crystal for these applications?

Kostya Makarchev:

I like to code in Ruby because I can do it very fast and it is very enjoyable. When I saw Crystal the first time in 2013, I already knew that it should solve all my problems. So first I rewrote a small daemon (200 lines of code) to Crystal in one day, and it just works, executing ten times faster than in Ruby. Later, I rewrote some small projects, and finally I rewrote the big backend project, 300K lines, and rewriting also was quite fast: sometimes I copied part of the Ruby code and it just compiled. I also tried Erlang, Go, and Node.js, but all these languages are not intuitive to code in for me.

But in Crystal I was amazed that I can code as fast as in Ruby. I can think an idea in my head and then just write code for it, without any pauses for language syntax or how to implement this or that. I just prototype and code my ideas, as fast as I can think. This is a great plus for Ruby or Crystal compared to other languages.

I think Crystal and Go are nice for network applications, or to replace event-machine from Ruby or Node.js projects. Go has better concurrency than Crystal, but Go is hard to think in, or to do fast prototyping, so I don’t like it. Also Erlang is nice for network apps, but to code in it is even harder. After using Crystal channel concurrency, I don’t like event-machine and Node.js concurrency anymore because they work with callbacks, which are a pain to debug.

Ivo:

What kinds of problems does Crystal solve best?

Kostya Makarchev:

Background processes, involving HTTP and concurrency.

Ivo:

What was it like to develop with Crystal?

Kostya Makarchev:

Rewriting was quite fun because I copied most of the Ruby code, and it worked almost without changes.

Ivo:

Are there any aspects of Crystal that specifically benefit customer satisfaction?

Kostya Makarchev:

Of course the speed of the production app, but also that it is rock stable and that it can be installed as one executable.

Ivo:

What advantages or disadvantages have you experienced from deploying a Crystal application in production?

Kostya Makarchev:

Deploying is super easy—I just use Capistrano: it compiles the binary on the target server after deploy.

Ivo:

What do you like the most about Crystal compared to other languages?

Kostya Makarchev:

I love Crystal as compared to Ruby in network applications because of the type checking, fast execution, and nice concurrency. All this in Ruby is just bad. But right now, I am not going to rewrite Rails apps to Crystal, or apps with a big usage of ActiveRecord because this functionality is not yet completely present in Crystal.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.165.115