• Optimisations for PostgreSQL serving Rails application

    As Senior Software Engineer at company building messaging platform for healthcare industry I am responsible, including other duties, for performance of our application. We develop pretty standard web-service using Ruby on Rails application for business logic and API, React + Redux for users' facing single page application, as database we use PostgreSQL. Common reasons for performance problems in similar stacks are heavy queries to database and I would like to tell the story how we applied non-standard but fairly simple optimisations to improve performance.


    Our business operates in US, so we have to be HIPAA compliant and follow certain security policies, security audit is something that we are always prepared for. To reduce risks and costs we rely on a special cloud provider to run our applications and databases, very similar to what Heroku does. On one hand it allows us to focus on building our platform but on the other hand it adds an additional limitation to our infrastructure. Talking shortly — we cannot scale up infinitely. As a successful startup we double number of users every few month and one day our monitoring told us that we were exceeding disk IO quota on the database server. Underlying AWS started throttling which was resulting in a significant performance degradation. Ruby application was not capable to serve all incoming traffic because Unicorn workers were spending too much time awaiting for database's response, customers were unhappy.

    Read more →
  • «Non-Blockchain Games Involving Money Must Die»



      Dmitry Pichulin, known under the nick «deemru», won the game Fhloston Paradise, developed by Tradisys on the Waves blockchain.

      The winner of Fhloston Paradise was supposed to be the player paying the very last stake during a 60-block period, before any other player could pay their stake and reset the counter to zero. The winner would collect all stakes paid by other players.

      Dmitry's winning recipe was the bot Patrollo, which he created. The bot paid just eight 1 WAVES stakes for Dmitry and eventually won him 4,700 WAVES ($13,100). In this interview, Dmitry discusses his bot and prospects of blockchain games.

      Read more →
    • Happy Potter and the Order of CSS


        So, first of all — this is not a common battle. It's not about CSS versus CSS-in-JS, not atomic CSS versus BEM, not LESS vs SASS. This battle is about THE ORDER.


        This battle is between ORDER and CHAOS. And between ORDER and,… another ORDER. In short — about a better way to sort CSS properties. No more, no less.


        In short — there are 3 ways to do it:


        • don't do it. Write any CSS as you can. This is the most popular way
        • group properties by sense. Just put some stuff together. This is a quite popular way.
        • order all the properties alphabetically. The easiest, but less popular way.
        Read more →
      • Indexes in PostgreSQL — 4 (Btree)

        • Translation
        We've already discussed PostgreSQL indexing engine and interface of access methods, as well as hash index, one of access methods. We will now consider B-tree, the most traditional and widely used index. This article is large, so be patient.

        Btree


        Structure


        B-tree index type, implemented as «btree» access method, is suitable for data that can be sorted. In other words, «greater», «greater or equal», «less», «less or equal», and «equal» operators must be defined for the data type. Note that the same data can sometimes be sorted differently, which takes us back to the concept of operator family.
        Read more →
      • .NET Core Container Images now Published to Microsoft Container Registry

          We are now publishing .NET Core container images to Microsoft Container Registry (MCR). We have also made other changes to the images we publish, described in this post.


          Important: You will need to change FROM statements in Dockerfile files and docker pull commands as a result of these changes. 3.0 references need to be changed now. Most 1.x and 2.x usages can be changed over time. The new tag scheme is decribed in this post and are provided at the microsoft-dotnet-core repo, our new home on Docker Hub.


          Summary of changes:


          • .NET Core images are now published to Microsoft Container Registry.
          • Updates will continue to be published to Docker Hub, for .NET Core 1.x and 2.x.
          • .NET Core 3.0 will only be published to MCR.
          • Nano Server 2016 images are no longer supported or published.

          image
          Read more →
        • Digital Forensics Tips&Tricks: How to Connect an Encase Image to the Virtual Machine

          • Tutorial
          I pretty often meet the question: how to attach an Encase image (.e01) to the virtual machine as a primary bootable disk? Sometimes a digital forensics experts need to boot up the image of the researching machine. It's not so hard actually, but this task has it's hidden stones which ones must be counted.

          For this case I'll use a VMware Workstation for Windows and VirtualBox for Linux as a virtualization platforms.

          Windows Part

          1. Open FTK Imager and mount the .e01 image as a physical (only) device in Writable mode


          Read more →
        • Flash-animation in Unity3D from scratch. Part one, lyrical

          • Translation

          In this article series, I will talk about how and why we decided to create our own solution for import of Flash animation to Unity, and about optimization techniques and internal workings of the plug-in. I also have lots of other fascinating stuff to tell about: internals of the SWF format, special features of the Unity editor extension and general matters of animation. You'll find all that inside!



          Read more →
        • Disposable pattern (Disposable Design Principle) pt.1


            Disposable pattern (Disposable Design Principle)


            I guess almost any programmer who uses .NET will now say this pattern is a piece of cake. That it is the best-known pattern used on the platform. However, even the simplest and well-known problem domain will have secret areas which you have never looked at. So, let’s describe the whole thing from the beginning for the first-timers and all the rest (so that each of you could remember the basics). Don’t skip these paragraphs — I am watching you!


            If I ask what is IDisposable, you will surely say that it is


            public interface IDisposable
            {
                void Dispose();
            }

            What is the purpose of the interface? I mean, why do we need to clear up memory at all if we have a smart Garbage Collector that clears the memory instead of us, so we even don’t have to think about it. However, there are some small details.


            This chapter was translated from Russian jointly by author and by professional translators. You can help us with translation from Russian or English into any other language, primarily into Chinese or German.

            Also, if you want thank us, the best way you can do that is to give us a star on github or to fork repository github/sidristij/dotnetbook.
            Read more →
          • Dozen tricks with Linux shell which could save your time



              • First of all, you can read this article in russian here.

              One evening, I was reading Mastering regular expressions by Jeffrey Friedl , I realized that even if you have all the documentation and a lot of experience, there could be a lot of tricks developed by different people and imprisoned for themselves. All people are different. And techniques that are obvious for certain people may not be obvious to others and look like some kind of weird magic to third person. By the way, I already described several such moments here (in russian) .

              For the administrator or the user the command line is not only a tool that can do everything, but also a highly customized tool that could be develops forever. Recently there was a translated article about some useful tricks in CLI. But I feel that the translator do not have enough experience with CLI and didn't follow the tricks described, so many important things could be missed or misunderstood.

              Under the cut — a dozen tricks in Linux shell from my personal experience.
              Read more →
            • Notifications: action required for take profit / stop loss. In case your Broker doesn't support those orders

                There is a Russian Broker — Tinkoff Bank. Now here is the problem: the broker doesn't support take profit and stop loss orders. At all. If you want to feel more convenient while trading, then you need some workaround for this situation, until Tinkoff Bank developers finally release those orders as the killer feature. In the article, I will show you my workaround.
                update:2019-03-22, the Broker published platform 3.0.0 (a major update) in Google Play. The changelog features take profit/stop loss orders
                Read more →
              • Info desk: global Internet initiatives



                  Fiber-optic cables are a great way to bring high-speed Internet right to your home or office. But even in large cities not everyone can enjoy the benefits of it, since apartments far away from everyone, or low-population districts far from downtown, are very reluctantly served by ISPs.

                  And then there’s small towns and villages, far away from the main Internet “highways”. In poorer countries, Internet is often slow and expensive even in large population centers, while villages are often left without a connection for years. To connect them to the World Wide Web takes the resources of not just normal ISPs, but telecom giants. Solar-powered drones with networking equipment, weather balloons, satellites and other similar projects are not just science fiction, but a reality today (or in the near future). But who’s closer to launch and who’s lagging behind? Let’s find out.
                  Read more →
                • Using Linux Kernel Sequence Files

                    A characteristic feature of modern programming is the use of the global network as a source of reference information, in particular, a source of patterns for solving unknown or little-known problems for a specific programmer. Such an approach saves a lot of time and often gives quite qualitative results. However, the solutions laid out in the network although usually correct, do not always take into account all the subtleties of solving a problem, which leads to the appearance in the source code of sections that usually work correctly, but under not quite standard circumstances become sources of unpleasant surprises.

                    Consider the topic of using sequence files in the Linux kernel, such files are considered to be the most convenient mechanism for printing from kernel mode. But in practice, using them correctly is much more difficult than you would think.

                    A lot of materials on this topic are available online. The best is the source code of the kernel itself which has quite detailed comments. The problem with this source of information is its volume. If you do not know exactly what to look for, it is better if you only have limited time, not to try at all. For me, when I became interested in the topic, Google provided several seemingly excellent sources of information relating to my search: the famous book The Linux Kernel Module Programming Guide and a series of articles by Rob Day. These sources are not new, but very solid.
                    Read more →
                  • Russian Internet Segment Architecture

                      As many of our readers know, Qrator.Radar is constantly researching global BGP connectivity, as well as regional. Since the Internet stands for “Interconnected Networks,” to ensure the best possible quality and speed the interconnectivity of individual networks should be rich and diverse, with their growth motivated on a sound competitive basis.

                      The fault-resistance of an internet connection in any given region or country is tied to the number of alternate routes between ASes. Though, as we stated before in our Internet Segments Reliability reports, some paths are obviously more critical compared to the others (for example, the paths to the Tier-1 transit ISPs or autonomous systems hosting authoritative DNS servers), which means that having as many reachable routes as possible is the only viable way to ensure adequate system scalability, stability and robustness.

                      This time, we are going to have a closer look at the Russian Federation internet segment. There are reasons to keep an eye on that segment: according to the numbers provided by the RIPE database, there are 6183 autonomous systems in Russia, out of 88664 registered worldwide, which stands for 6.87% of total.

                      This percentage puts Russia on a second place in the world, right after the USA (30.08% of registered ASes) and before Brazil, owning 6.34% of all autonomous systems. Effects of changes in the Russian connectivity could be observed across many other countries dependant on or adjacent to that connectivity, and ultimately by almost any ISP in the world.
                      Read more →
                    • Top 10 bugs of C++ projects found in 2018

                        It has been three months since 2018 had ended. For many, it has just flew by, but for us, PVS-Studio developers, it was quite an eventful year. We were working up a sweat, fearlessly competing for spreading the word about static analysis and were searching for errors in open source projects, written in C, C++, C#, and Java languages. In this article, we gathered the top 10 most interesting of them right for you!

                        Read more →
                      • What's new in CUBA 7

                          What's new in CUBA 7


                          Three years ago we announced the second publicly available major version of the framework. CUBA 6 was the game-changing version — the licensing was turned from proprietary to Apache 2.0. Those days we couldn't even guess where it was going to bring the framework in long term. CUBA community started to grow exponentially, so we have learned a lot of possible (and sometimes impossible) ways of how developers use the framework. Now we are happy to announce CUBA 7, which, we hope, will make development more coherent and joyful for all community members from those just starting their journey in CUBA and Java to skilled enterprise developers and Java experts.


                          cuba

                          Read more →
                        • Indexes in PostgreSQL — 3 (Hash)

                          • Translation
                          The first article described PostgreSQL indexing engine, the second one dealt with the interface of access methods, and now we are ready to discuss specific types of indexes. Let's start with hash index.

                          Hash


                          Structure


                          General theory


                          Plenty of modern programming languages include hash tables as the base data type. On the outside, a hash table looks like a regular array that is indexed with any data type (for example, string) rather than with an integer number. Hash index in PostgreSQL is structured in a similar way. How does this work?

                          As a rule, data types have very large ranges of permissible values: how many different strings can we potentially envisage in a column of type «text»? At the same time, how many different values are actually stored in a text column of some table? Usually, not so many of them.

                          The idea of hashing is to associate a small number (from 0 to N−1, N values in total) with a value of any data type. Association like this is called a hash function. The number obtained can be used as an index of a regular array where references to table rows (TIDs) will be stored. Elements of this array are called hash table buckets — one bucket can store several TIDs if the same indexed value appears in different rows.

                          The more uniformly a hash function distributes source values by buckets, the better it is. But even a good hash function will sometimes produce equal results for different source values — this is called a collision. So, one bucket can store TIDs corresponding to different keys, and therefore, TIDs obtained from the index need to be rechecked.
                          Read more →
                        • React Code Splitting in 2019

                            It's 2019! Everybody thinks they know code splitting. So - let's double check!



                            What does code splitting stand for?


                            In short – code splitting is just about not loading a whole thing. Then you are reading this page you don't have to load a whole site. When you are selecting a single row from a database – you don't have to take all.
                            Obvious? Code splitting is also quite obvious, just not about your data, but your code.

                            Read more →