红联Linux门户
Linux帮助

Building cloud-ready, multicore-friendly applications, Part 1: Design principles

发布时间:2009-03-31 14:19:48来源:红联作者:jerry520
Multicore processing power and cloud computing are two of the most exciting challenges facing software developers today. Multiple chips or processing cores will enable individual computing platforms to process threads unbelievably fast, and the advent of cloud computing means that your applications could run on multiple distributed systems. In this first half of a two-part article, Appistry engineer Guerry Semones gets you started with the four design principles for writing cloud-ready, multicore friendly code: atomicity, statelessness, idempotence, and parallelism. Level: Intermediate

With the advent of cloud computing, the explosive growth of mobile device use, and the growing availability of multicore CPUs, there is a drive toward new models for designing and developing code. Well, they're not new, really. Some of the models have been around, and in use, for some time, but they're not typically practiced by mainstream developers ... yet.

Michael Groner wrote about this trend in a blog post entitled "Microsoft says you need to change how you are building your applications." Here is part of what he said:

I was surprised how many speakers [at Microsoft TechEd 2008] were conveying the same message: CPU speeds are topping out. If you want your applications to run faster and better you are going to have to build your applications in a new way. The solution isn't just to learn how to multi-thread your applications. The solution lies in building your applications into smaller units of code called tasks that can be moved around to the different cores of a multicore machine.

The message that the time had come to "take programs and break them down into parallel execution units" was music to Michael's ears.

Why? It is the same model that we [at Appistry] have been using for fabric computing since our beginnings in 2001. Now we are starting to see this message more and more as cloud computing is gaining acceptance.

For your applications to meet the demands of computing in a cloud-based, multicore world, you'll need to design your code with the following attributes in mind:

* Atomicity
* Statelessness
* Idempotence
* Parallelism

In this article, the first of two parts, I'll discuss each attribute in turn and then explain what it means in practice, when you write code. In the next article you'll get a glimpse of how applications written to maximize these four attributes can reap the benefits of various multi-processor, distributed architectures.
Atomicity

An atomic piece of code has a specific and clearly defined purpose. In object-oriented terminology, it has cohesion. Atomic code adheres to Robert Martin's single responsibility principle, where not only classes but methods have distinct jobs, each method having a single concern. Such code is like a delicious, pepperoni pizza, not the garbage pizza loaded with everything. Additionally, atomic code does not rely on a specific order of execution.
文章评论

共有 0 条评论