By Luis Armando Uvalle, Software Architect at BairesDev.
Have you ever realized that time is irreplaceable?
Time, as far as we know and are capable of knowing, is the only physical variable that can go in one and only one direction: forward. The value of things is how much those things are essential to us. Irreplaceable things are sometimes, if not always, the most valuable of all. We even refer to those things as “invaluable” or “priceless.”
Time is an irreplaceable resource. In a way, when we save time, we save something invaluable. In this article, I will explore two cases where this invaluable resource was well managed and saved, leveraging parallel technology. This allowed several tasks to be done simultaneously, and the total amount of time required was less than if those tasks were processed one after the other.
What Is Parallel Technology?
The only way to accomplish parallel processing is to have two or more devices (microprocessors) inside a computer and assign a single task to each of those microprocessors. But considering we are talking about computers that we are all familiar with, and ordinary computers have only one microprocessor, how can a computer have multiple tasks running simultaneously? Nowadays, microprocessors are composed of two or more nuclei, called cores, considered as microprocessors encapsulated in a single chip. However, the total number of cores in a microprocessor is eight or fewer, and computers can have more than eight applications running simultaneously. How is it possible?
The answer is that microprocessors are much faster than RAM (random access memory, the computer’s internal memory). Even if a computer only has one microprocessor with only one core, it can process pieces of several tasks so fast that even though those pieces of tasks are actually processed one by one, we have the impression that they are done at the same time.
Quantum computers are the only ones that have real parallel processing technology, but they are beyond the scope of this article.
Case 1: From 10 to 4
There was an application that wasn’t designed by my IT team. That application ran a process that used to require a little more than 10 minutes to be done. My technical leader and I were asked to check if there was a chance to make the process faster.
There was no documentation or contact with the original designers to ask about the application, so we started to analyze the code without previous knowledge of it.
I analyzed the code and implemented some optimizations to reduce the time to one or two minutes—no big deal. However, my technical leader realized that the whole process consisted of smaller subtasks and, most importantly, those subtasks didn’t depend on each other, so they could be processed in parallel.
With asynchronous programming, I assigned a thread to every single subtask, and in the meantime the main thread was available for the user. Every time a subtask was finished, the result was stored. When all subtasks were completed, all those single results were processed to get a final result.
With parallel technology, the total time needed to complete the process was reduced from over 10 minutes to around 4.5 minutes—a time saving of over 50%. It was a really exciting and very satisfactory outcome.
I think the success of this project can be summarized in three points:
- Analysis — The product’s analysis let us realize that the subtasks were independent from each other, so they could be processed in parallel. Remember that we didn’t have any documentation nor contact with the original designers.
- Mastering technology — The knowledge of asynchronous capability of .NET Technology with C# allowed us to implement the parallel processing solution.
- The importance of documentation — I’m quite sure that if there had been documentation, we could have accomplished our assignment in much less time.
Case 2: “Free” the Web Application
A hardware manufacturer needed an application to retrieve information about computer images for their laptops line. They needed a web service capable of being consumed by a web application. The internal client was in the United States, and the development team was in Mexico.
The client needed a brand-new web service to consult information. This process took around five minutes to be completed. It was necessary to free the web application for the user to be able to do something else while the request was processed.
To achieve that, the web service would first need to send the user a confirmation when the request was received; then process it behind the scenes while the user was doing something else on the computer, such as using another application, knowing that the other task was being processed in parallel; and finally return a result to the user when it was done.
The request was broken down into subtasks, and every team member was assigned some to implement. Those subtasks were related, so coordination between the subprocesses was necessary. There was a log, too, in order to keep track of requests.
The whole project was designed and implemented from scratch by my IT team, which was composed of four .NET developers, including myself.
- Technological platform: .NET
- Programming language: C#
- Database mapping framework: Entity Framework
- Database: SQL Server
The only way to accomplish the client’s requirement was to implement parallel technology. Optimization changes to the SQL database design were implemented in order to reduce processing time. With asynchronous programming, all those subtasks were processed according to the requirements and the user could do something else with a free web application.
We met all the internal client requirements in the United States and received no complaints about the application upon completion. We are certain it saved a lot of time.
For me, the most satisfactory points from this project are:
- Design and coding — My IT team designed and implemented the whole application from scratch.
- Teamwork — Every team member was able to accomplish individual assignments and create a satisfying result together.
- Mastering technology — The knowledge of the asynchronous capability of .NET Technology with C# allowed us to implement the parallel processing solution.
- Meeting the client’s expectations.
If parallel technology is so great, one might wonder, why not always use parallel technology? The answer is simple: because it’s more complex and costly than nonparallel technology. As the saying goes, “There’s no free ride.” Parallel technology may be worth the additional cost, depending on your needs, so it’s crucial to know them thoroughly.
Consider parallel technology if the needs described in the cases resonate with your current challenges. It might just be the game changer for your technology and business.