📜 ⬆️ ⬇️

RailsClub 2017: Interview with Richard Schneeman

Hello!

We are preparing for the upcoming RailsClub 2017 conference (everything will happen on September 23) and talk with our speakers about life and programming. Today, Mikhail Morgunov spoke with Richard Schneeman from Heroku, Ruby Hero 2016, Top 50 Rails contributors.

image
')
Why in the report do you want to talk about threads in Ruby?

Many do not use streams because it is difficult. Yes, inside Ruby there are a bunch of factors that complicate things — for example, global variables or Global VM Lock (GVL). Developers mistakenly believe that using threads is difficult because GVL makes them less useful. And supposedly, therefore, we cannot use them inside Ruby. I try to show that there are arguments for using streams in Ruby, there are suitable scenarios for this. Yes, using threads is hard, and not only in Ruby, but in any other programming language. I have experience with multithreading in C and everything is much worse with it! Ruby is not the easiest language to work with streams, but certainly not the most difficult. When we develop applications, we can see how threads provide a significant increase in performance. For example, background tasks. I have a library called Puma Worker Killer . It can be used, for example, to restart a cycle once every 4 hours. Without threads, this is impossible to implement, so I used threads as the basis of the library. That's why I decided to make such a report.

Where are you using streams now?

At the moment, I am engaged in support:

- Puma Worker Killer
- A library called Threaded (implementation through a thread pool)
- Concurrent Ruby

With the help of threads, we can run checks in parallel, which will be executed simultaneously. As a result, it is 6 times faster.

How many threads can we run simultaneously and how much memory will it take?

This is one of the most difficult questions in the world! :) I once asked a university professor about this, and she could not give me a good answer. In general, you can run as many threads as there are CPUs. Find out how many cores you have from the processor, and run as many threads. Each stream addition reduces the amount of available memory. Another alternative is to use separate processes. But they use much more memory than threads. Ruby uses a lot of memory by itself, so using only processes will require a huge amount of memory. Reason number one, why you should use streams is the correct use of memory. The second reason is I / O. When I / O is used somewhere, then streams should be used. In short: the number of CPUs = the number of threads. A good amount to start with is 5. Starting from there, you can increase or decrease the number of threads, depending on your system. And to say a specific number is really difficult.

How did you become a programmer?

I started studying Ruby at the university. At that time, websites and web applications were very popular, everyone was talking about them. I heard about the success of Bill Gates and thought, “Wow! I want to be like him! I want a billion dollars! ” I asked a roommate who was studying at the Faculty of Computer Science how to make a website. He said that one of the popular websites of the time uses Ruby on Rails. I bought the book “Ruby on Rails for Dummies”. At the university I studied as an engineer to eventually make refrigerators, and it was very boring. As a result, I spent all my free time developing websites and learning. I liked it so much! I started going to the developer mitapas, joined the user groups. Well, from about this time I started doing this professionally.

What advice would you give to a newbie?

Try to find something that will bring you a million dollars! :) Sometimes people ask me: “How to become a programmer, how to learn it?”. I ask them to take a step back and ask themselves: “What do I want to create in the end”? Can you imagine it? It can be anything, but having a clear idea in your head is very important. The most difficult part of programming is not the technical aspect. The most difficult thing is not to lose interest and be delighted with your work. Find something that inspires you and do not stop!

What is your hobby? What do you do in your free time?

Hand work, I like carpentry. But right now I have no free time, because I entered the magistracy and it takes him 100%. And in December I will have a new hobby - my second child will be born. I'm really looking forward to this! Children are full-time, so I will take a two-month break from work, I will take care of my family, and I will consider all other activities as a hobby.

You can read the original interview in English at hype.codes .

Richard's report on the upcoming RailsClub is called Aren't Evil Threads, come and ask all the remaining questions personally!

Register , there is not much time left!

Source: https://habr.com/ru/post/337378/


All Articles