Thread Pool

18 Mar 2011

Thread Pool

Thread Pool

In previous post you may understand the architecture of single thread and thread per request in distributed systems. Here we will see another architecture called Thread Pool. Thread pool pre-defines a number of thread running in its pool. Let’s say we have 2 threads in the pool, then the server is capable of running only 2 requests at the same time. Other requests must wait in queue until the 2 threads in the pool finish their work. In real world applications, we see a lot of servers fall into this category. For example, Apache web server, IIS server, etc. The advantages and disadvantages are discussed below:

Continue Reading »

No responses yet

Thread per Request

17 Mar 2011

Thread per Request/Connection

Thread per Request/Connection

Thread per request or connection has been introduced in order to maximize the system resource and provide responsiveness to users which single thread is not capable. Thread per request or connection architecture will create a thread for each request from a client. In other words, server can create a number of threads as per request. The only limitation is software and hardware capacity. Thread per request is one among thread in distributed systems architecture. This architecture is coming with advantages and disadvantages.

Continue Reading »

No responses yet

Single Thread Server

16 Mar 2011

Single Thread

Single Thread

Single thread server is one among concurrency architecture in distributed systems. It is the early stage of distributed systems development. Its footprint is very small and easy to develop. Single thread has an ability to handle only one user a time. The other users must wait in queue until the working user finished his or her task.

If we consider about CPU and I/O usage, single thread is not fully utilized because while CPU is busy I/O usually is free and vice versa.

The development of a single thread server is the same as my example in UDP Programming with Java and TCP Programming with Java.

Advantage

  • Straight forward
  • Easy to develop

Disadvantage

  • Waste time. CPU and I/O are not fully utilized
  • User unsatisfactory because user may wait for getting services
  • May be not exists in real world distributed systems application

 

No responses yet

Thread in Distributed Systems

15 Mar 2011

Thread in Distributed Systems

Thread in Distributed Systems

One challenge in distributed systems is concurrency. Without supporting multithread, distributed systems is almost meaningless as it needs to support multiple users. It is typical in distributed systems to have tasks that are partly CPU intensive and partly I/O bound. Generating database query, rendering an image, etc are examples of CPU intensive. Sending files or requests over the network are I/O intensive related to Socket, RMI, etc.

Now we will lookup 3 main architectures that thread impact the performance of distributed systems.

  • Single thread
  • Thread per request or connection
  • Thread pool

Continue Reading »

No responses yet

Parallel and Distributed Computing

13 Mar 2011

Parallel and Distributed Computing

Parallel and Distributed Computing

Parallel and Distributed computing can be confused. This article will show you the simplest way to identify.

Parallel Computing

  • Shared memory system
  • Multiprocessor (multiple processors share a single bus and memory unit)
  • Symmetric Multiprocessing (SMP) supports in Operating System
  • Much simpler than distributed system
  • Limited scalability

Distributed Computing

  • Distributed memory system
  • Multicomputer (Autonomous computer nodes connected via network)
  • Share many of challenges
  • Better scalability and cheaper
  • Distributed computing in local network is also called cluster computing while in wide-area networks is referred to grid computing

 

One response so far

Challenges in Distributed Systems

13 Mar 2011

Challenges in Distributed Systems

Challenges in Distributed Systems

Designing the distributed systems does not come for free. Some challenges need to be overcome in order to get the ideal systems. The challenges in distributed systems are:

  • Heterogeneity
  • Transparency
  • Openness
  • Concurrency
  • Security
  • Scalability
  • Resilience to failure

Continue Reading »

18 responses so far

Stub and Skeleton

11 Mar 2011

Stub and Skeleton

Stub and Skeleton

Java RMI is powerful middleware that replaces raw request/reply method as UDP and TCP. The core technology to make it works is Stub and Skeleton function. Stub is located on the client side while Skeleton is located on server side. The role of stub and skeleton is to do marshalling and unmarshalling meaning that it will squash the argument and return value of a method to be a standard format for storing in a file or transferring over the network. Without Stub and Skeleton, java RMI cannot work.

Note on Stub and Skel files (Skeleton)

  • Java JDK 1.6 does not require to have Stub and Skeleton file (Skel for short) as it takes advantage of reflection to accomplish the task
  • Java JDK 1.5, it requires only Stub file at the client. To generate stub file:
    • rmic PowerServer
    • PowerServer_Stub.class will be generated
  • Java JDK prior to 1.4 (not quite sure), it requires both Stub and Skel files
    • rmic -vcompat PowerServer
    • PowerServer_Stub.class and PowerServer_Skel.class will be generated

2 responses so far

How to Run Java RMI?

11 Mar 2011

There is a tricky in getting Java RMI works and runs. First, you need to understand the Overview of Java RMI and know how to implement it. Java RMI relies on 3 components–client, server and registry service.

Note: This article refers to the code developed in How to Implement Java RMI.

Registry Service

There are 2 ways to deal with registry service.

  • Run rmiregistry command in Dos prompt or Console if it is not created in the code
  • Create RMI registry service in the code

Registry registry = LocateRegistry.createRegistry(1099);

    Server

    • It needs interface class(IPower.java) created in Step 1 of How to Implement Java RMI article
    • Run java PowerServer

    Client

    • It also needs interface class (IPower.java)
    • Be sure that you pointed to the right server’s registry service
    • Run java PowerClient

    No responses yet

    How to Implement Java RMI?

    10 Mar 2011

    Java RMI Implementation

    Java RMI Implementation

    Implement Java RMI could be ever easier if you follow my rule strictly. You need to understand Java RMI Overview before you can catch the code.

    According to the above figure, there are 4 steps need to be involved in Java RMI development. I will give you an example of creating Java RMI application dealing with Fibonacci and Factorial calculation using badly recursive algorithm. These two methods will be available for invocation at the server side. I will call the server program as PowerServer and client program as PowerClient.

    Continue Reading »

    2 responses so far

    Java RMI Overview

    08 Mar 2011

    Java RMI Overview

    Java RMI Overview

    Java RMI or Remote Method Invocation is an example of Remote Procedure Call (RPC) enabling client program to locate the server object and remotely invoke the methods from server through server’s stub and skeleton function. Java RMI is usually referred to Distributed Object rather than RPC. This is because Java natively is object oriented programming. So we say object as a whole. Moreover, RPC somehow is mentioned to procedural programming.

    Continue Reading »

    One response so far