RailsClub 2017: Interview with Richard Schneeman

    Hello!

    We are getting ready for the upcoming RailsClub 2017 conference (everything will happen on September 23) and we are talking with our speakers about life and programming. Today, Mikhail Morgunov spoke with Richard Schneeman of 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 threads because it is complicated. Yes, inside Ruby there are a bunch of factors that make things complicated - for example, global variables or Global VM Lock (GVL). Developers mistakenly believe that using threads is difficult because the GVL makes them less useful. And supposedly therefore we cannot use them inside Ruby. I try to show that there are arguments for using threads in Ruby, there are suitable scenarios for this. Yes, using threads is hard, and not just in Ruby, but in any other programming language. I have experience with multithreading in C and there it is much worse! Ruby is not the easiest language to work with threads, but certainly not the most complex. When we develop applications, we can see how threads provide a significant increase in productivity. For example, background tasks.Puma Worker Killer . It can be used, for example, to restart the cycle every 4 hours. Without threads, this is impossible to implement, so I used threads as the basis of the library. That is why I decided to make such a report.

    Where do you use streams now?

    At the moment, I am supporting:

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

    Using threads, we can run checks in parallel, which will be performed 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 professor from the university about this, and she could not give me a good answer. In general, you can run as many threads as there is a CPU. Find out how many cores you have on your processor and run as many threads. Each addition of a stream 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 on its own, so using only processes will require a huge amount of memory. The number one reason why you should use threads is the correct use of memory. The second reason is I / O. When I / O is used somewhere, you need to use streams here. In short: number of CPU = number of threads. A good amount to start with is 5. Starting with it, 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 university. At that time, websites and web applications were very popular, everyone just talked 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 studied at the Faculty of Computer Science how to make a website. He said one of the popular websites of the time was using Ruby on Rails. I bought a book called “Ruby on Rails for Dummies”. At university I studied as an engineer in order to make refrigerators in the end, and it was very boring. As a result, I devoted all my free time to website development and self-training. I liked it so much! I started going to developer meetings, joined user groups. Well, about this time I began to do this professionally.

    What advice would you give 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 this?”. I ask them to take a step back and ask themselves: “What do I want to create in the end?” Can you imagine that? It can be anything, but having a clear idea in your head is very important. The hardest part of programming is not the technical aspect. The most difficult thing is not to lose interest and be delighted with your work. Find what inspires you and don’t stop!

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

    Work with hands, I really like carpentry. But right now I do not have free time, because I entered the magistracy and it takes it 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 a full-time job, so I will take a two-month break from work, I will be engaged in my family, and I will consider all other classes as a hobby.

    Read the original interview in English at hype.codes .

    Richard's talk at the upcoming RailsClub is called Threads Aren't Evil, come and ask all the remaining questions in person!

    Register , there is very little time left!

    Also popular now: