Thursday, June 11, 2009

How many CPUs your operating system can handle?

How many CPUs your operating system can handle? 2 / 4 / 8 – many a times ans is very simple – I don’t know? How to find the answer? Here is one easy way to get to the bottom of this issue. Go to the Task Manager and right click on any process , and then click on the set affinity option as shown below. You will get the answer. Note: this is the number – how many CPUs can be managed by your OS and not the underlying hardware.






And here are the specs for a machine I used in this excercise


Sunday, May 3, 2009

Multiplexing strategy for reducing software licensing cost

Software licensing is a complex and confusing topic. Most of us know how to use and master any given software like SQL Server, Oracle, or Crystal Report etc. But purchasing a software and figuring out the real cost is a challenge. Questions like do you want to go with named-users or per core licensing or on the basis of number of processors or total number of CPU’s are confusing. For example, Microsoft will charge you based on the number of processors in your server irrespective of number of CPUs / core per processor and Oracle will treat each core as half the processor. For example, on 4 quad core server [4 processors with 4 CPUs on each processor = 16 CPUs or cores], SQL server will cost you for 4 licenses and Oracle will result in 8 licensees [16 * 0.5 =8] [1]

Now this might be acceptable for enterprise grade tools like RDBMS or reporting solution. But many a time we end up buying 8 or 10 copies of small commodity software used by a department or a group of users working on a special project. Most of these tools are sold on per instance basis. So we end up paying for 10 copies and installing it on individual desktops. This also results in maintenance nightmare.

There is a better way to deal with such commodity tools – strategy known as multiplexing. It’s very straight forward – all you have to do is to install one instance of the commodity software on your central server and write a wrapper around it. The wrapper can be exposed over the network [LAN / WAN / Internet] using http, https etc. Yes, you will have to write a web application that will expose the interface for the commodity tool. Many a times, this strategy will work like a charm [except if licensing agreement for the commodity tool explicitly deny the permission for any such exercise]. Note – this does not involve changing any of the bits / code in the commodity software – all you are doing is to expose its public interface over the network. Threading and deadlocks might pose some challenge when shared resources are simultaneously utilized by many users. But this can be avoided by placing an explicit lock on shared resources like file folders. Additionally, this public interface can be modified to accept the inputs from internal resources like local databases, file system etc.

If used judiciously, multiplexing can deliver a great business value.

Reference:

1.http://www.microsoft.com/Sqlserver/2005/en/us/special-considerations.aspx

Monday, April 20, 2009

Web 2.0 and Cloud Computing

It is always good to compare different technologies. That way we can see whether the technology is maturing with time and is worth considering it for real. But the challenge is to find a tool that would help in this endeavor. I found “Gartner Hype Cycle” [GHC] really effective in comparing different technologies and their evolution.

So I wanted to see how web 2.0 is doing over last three years and where does cloud computing stand on this technology curve. I always believed that image is worth thousand blogs…so here you go – GHC for 2006, 07 and 2008 and the evolution of web 2.0 vs. cloud computing. ..







Reference
for 2006
http://www.saastream.com/my_weblog/images/2007/10/02/gartner_hype_cycle_emerging_techn_4.jpg
for 2007
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKRtg86I2SFDcA_IyZK3lG8u5d7KOpX0eEQAaPqmLqlT7k9wLr61vlCbEYmruMdU__jyGJBIBN-scyV7gkIi21CZGD91Bzhlu2XlQ1LKZV58qpTUe39xP7PpJLC1RNEuayK-Latvy45mTF/s400/hype-cycle-for-emerging-technologies-2008-400.jpg
for 2008
http://www.flickr.com/photos/lafabriquedeblogs/2796357787/

Sunday, April 19, 2009

Virtualization : as experienced from ground zero

Virtualization is a big theme in the contemporary enterprise architecture. Many documented case studies highlights the virtualization benefits including better hardware utilization, grater ROI and lower TCO. This deal is so great that you can’t overlook this option…




But, and this but is a big one. But the reality is not that green. From software point of view, it is not able to utilize 100% of the physical infrastructure. Like in our example, we have 8 CPUs and 128 GB of RAM, but each virtual machine can only use up to 4 CPUs and 64 GB of RAM. Systems like RDBMS thrive in many-core / multi-processor environment. So by limiting the number of CPUs or memory, we are minimizing its capacity. This is what we experienced when we decided to use a hypervisor [and this is mostly true for any hypervisor].

In future version of hypervisors, this limitation will be fixed. Based on the processing load, each VM will be able to optimize the physical resource utilization. But as of today, there are some hard limits on no of CPUs and RAM each VM can use.

So to conclude, in our test case – let’s compare machine A with 8 CPUs and 16 GB of RAM with machine B with 8 CPUs and 128 GB of RAM. Machine B is virtualized and is used to run 2 VMs with 4 CPUs each and 64 GB of RAM. Both the VM’s on machine B are operating in parallel and are used for running an instance of SQL Server 2005 and a file server. Which SQL Server instance will run fast – one that is running on machine A or on machine B? What if we bump up the RAM in machine B up to 256 GB? These are some solid question one should consider seriously before jumping on the virtualization bandwagon. Yes, all these issues will be fixed in the future versions and all vendors are working on it. But from pure architecture point of view, as of today, one should consider these limitations seriously.

A lot will depend on the processing load and type of applications running on these virtual machines. For busts and spikes – you need a ton load of RAM and huge processing for a while but after that all that capacity is just idling around. What if that bust or spike is the reason for provisioning such a huge hardware capacity? Can we run this busty system in a virtualized environment and let it suffer because of VM’s limit on no of CPU it can handle and maximize our hardware utilization or go the traditional way and provision a big machine just to handle this one mission critical load efficiently and effectively? These are some critical questions one would face while moving the production applications in a virtualized environment. There are no easy answers and the only way to insure the success is by doing as much testing as possible.

Sunday, February 1, 2009

On the Benefits of Learning Multiple Languages

Finally, I got to the pile of magazines I wanted to read for long time. I found this article in Visual Studio magazine. I liked the title and started reading it. The basic premise is – “Learning other programming languages can make you more fluent and give you a better understanding of the language you depend on primarily.”

So I started coding in the language I know the best – C# and wrote some code


using System;

namespace demo
{
internal class Test
{
public static void Main()
{
const int i = 2;

//static method call
Console.WriteLine(IsEven(i));

//generic delegate
Func<int, bool> f = IsEven;
Console.WriteLine(f(2));

//anonmous method + lambda
Func<int, bool> f1 = j => j%2 == 0;
Console.WriteLine(f1(2));

Console.ReadLine();
}

public static bool IsEven(int number)
{
return number > 0 ? number%2 == 0 : false;
}
}
}

Now, I wanted to convert this code to visual basic. Interestingly, I found a decent conversion method to get this thing done. I used .NET reflector. I used reflector to disassemble C# .exe and then to convert the code to VB. Reflector did a good job and produced following VB code


Friend Class Test
' Methods
Public Shared Function IsEven(ByVal number As Integer) As Boolean
Return IIf((number > 0), ((number Mod 2) = 0), False)
End Function

Public Shared Sub Main()
Console.WriteLine(Test.IsEven(2))
Dim f As Func(Of Integer, Boolean) = New Func(Of Integer, Boolean)(AddressOf Test.IsEven)
Console.WriteLine(f.Invoke(2))
Dim f1 As Func(Of Integer, Boolean) = j => ((j Mod 2) = 0)
Console.WriteLine(f1.Invoke(2))
Console.ReadLine
End Sub

End Class

The only point it tripped is on the lambda expression syntax =>. So, I had to do a little bit of Googling to find the correct VB syntax. And, finally got the VB code like


Friend Class Test
' Methods
Public Shared Function IsEven(ByVal number As Integer) As Boolean
Return IIf((number > 0), ((number Mod 2) = 0), False)
End Function

Public Shared Sub Main()

Console.WriteLine(IsEven(2))
Dim f As Func(Of Integer, Boolean) = New Func(Of Integer, Boolean)(AddressOf IsEven)
Console.WriteLine(f.Invoke(2))
Dim f1 As Func(Of Integer, Boolean) = Function(j) j Mod 2 = 0
Console.WriteLine(f1.Invoke(3))
Console.ReadLine()

End Sub
End Class

I enjoyed this exercise. In fact, in the same edition of the VS magazine, I found couple of interesting articles - What VB Devs Should Know About C# and What C# Devs Should Know About VB.

If you are involved in any migration effort from VB to C# or vice versa, or work in the mix environment with a lot of VB and C# code co-existing peacefully , then you will find these articles really useful.

Sunday, November 2, 2008

Towards Distributed Applications…

2008 is the year when we saw the commercial emergence of the many-core / multi -core hardware architecture. As a result of this, field of distributed computing is really buzzing with a lot of activities and cool technologies. Two such projects that attracted my attention are project Volta and DryadLINQ in Microsoft domain and Lively Kernel in the Java world. Let’s focus on Dryad and Volta first.

One common thing about Volta and DryadLINQ is that they focus on making distributed computing easy for the common programmer like me. [DryadLINQ documentation refers to this class of programmers as ordinary programmer – LOL!] . The strategy here is to abstract away the underlying complexity in building the distributed systems and to minimize the disruptive impact of the new technology.


This goal is achieved by focusing on different levels of the .NET implementation stack. This way, as a developer, I can still write my same old C# / VB sequential, LOB code and the technology will transform it into a distributed application.

As with any new technology, there will be few bumps on the road. At the time of writing this post, I found following message on the Volta site –

“Project "Volta" Temporarily Unavailable”

Good news is that big vendors like Microsoft and Sun are taking the bull by the horns. There is no one right answer in solving this complex problem of converting existing sequential , single processor LOB applications into multi-core/ many-core enabled , inherently parallel, distributed applications. We will witness multitude of solutions on hardware and software level. We have seen this gold rush before in the good old days of RDBMS emergence. Let’s hope that same thing will happen with the distributed computing infrastructure.

For more details on Volta and Dryad, check out the following links and publication

1.http://channel9.msdn.com/posts/Charles/Erik-Meijer-Volta-Wrapping-the-Cloud-with-NET-Part-1

2.Volta: Developing Distributed Applications by Recompiling, IEEE Software Sept/Oct 2008 issue

3.http://research.microsoft.com/research/sv/dryad/

Monday, October 27, 2008

Caching in the Distributed Environment Slides

I did a presentation on "Caching in the Distributed Environment" at SoCal Code Camp 2008. Here is the link from where you can download this presentation

http://www.scribd.com/doc/7564192/Caching-in-the-Distributed-Environment

Let me know if you have any questions / suggestions

thanks.

abhi