Talking to Databases

Crystal comes out of the box with a database library to work smoothly with SQLite, MySQL, and PostgreSQL. Stefan Wille[17] compared the performance of a Redis client-library in different languages talking to Redis in a pipelined mode. This means that the client queues up all 1,000,000 requests, sends them in one big batch, and then receives all responses in another batch, which minimizes the impact of the operating system and focuses the measurement on the overhead caused by the client library and by the programming language.

The results, represented in number of commands handled per second, are quite persuasive. (The two “Ruby” entries on the right use different Redis client libraries.)

images/why_crystal/Redis_client_library.png

From the evidence you saw in the preceding sections, it will come as no surprise to learn that Crystal can be effectively applied for web servers, heavy-lifting backend server processing, command-line tools, microservices, working with databases, and even games.

Apart from the speed, what other advantages does Crystal bring to the table?

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

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