Parallel Programming – Should It Be Used on Single CPU Cloud Platforms?

cloud computingcpumultithreadingparallel programming

Almost every cloud instance I can find defaults one CPU. Why is this only one CPU now, and should I expect this to increase in the future?

Does this design impact my code design so that I exclude technologies like Task Parallel Library?

This is on topic to Programmers.SE because it impacts the long-term scalability of muti-threaded code on cloud platforms.

Best Answer

Cloud computing deals with ridiculously parallel problems by default, like serving up resources from a URL. There are several ways to achieve parallelism, regardless of the number of cores you have. You should build your application knowing how you intend to take advantage of it. You can get cloud instances with multiple cores and lots of RAM, but they cost more.

Most web services run within an embedded web server (like Spring Boot web services for example). The parallelism you need is taken care of by the server, so as long as you don't add points of contention your service remains ridiculously parallel and you don't have to think about threads at all.

That said, one service can only handle so many clients at once. That's why cloud solutions typically bring another instance online and distribute traffic between the instances of your service. Many times it is much cheaper to have another instance for a short burst of traffic than it is to have one instance with multiple cores.

What you aren't seeing is that your service is usually hosted on a server with multiple cores, but it only looks like one to you. When you have multiple copies of your web service running, you are also using multiple cores.

The point being the parallelism is there, you just need to know how not to mess it up. For that you need to understand how parallelism works, etc.

You mentioned the Task Parallel Library, and that is a key feature in Microsoft's approach for web services--particularly when paired with async and await. Understanding how that works will really help your application handle more concurrent users. It is time well spent.

Related Topic