Friday, October 5, 2012

Ubuntu /centos virtual machine doesn't have IP address/ can't connect to network?

you may turn on the NAT/Bridget/HOST ONly setting for your GUEST OS, but when you run the ifoncfig, there is no IP v4 address associated.
image

Basically, make sure on the HOST machine, the vmware/virtualbox DHCP service are running,
image
then run dhclient eth0, you should be able to get a IPv4 address.

for the windows host machine, the dhcp range are stored in the registry. so make sure the VMnet NIC ip address match the network address, otherwise, from the host machine, you can’t ping or access the guest OS.

image

Thursday, October 4, 2012

asp.net output cache not working? and the same code works on some servers? why

Here is one very typical issue that bring you to this blog.
Issues, I have one asp.net application with nothing special, for the performance consideration, we turn on the output cache. somehow, the same page never got cached on some servers, and It did cached on most servers. of vice versa.

short answer, It has nothing to be with the IIS Version. It’s All about HTTP Cookies and .net Framework version.  Let’s put a very basic Page.

just turn on the output cache using the most simple way,
image

for the code, we just send out some cookie,
image

Let’s start from some server that it works,
1st time you hit the url, get a initial access time.

image

  and cookie was sent to client from server side,
image

try again, this page will be cached. you are always see the page, you are 1st time here,
image

Why? because we setup the page need to be cached for 600 seconds, and cache response vary by any params, if we add something to the url parameter, we wills see refreshed page,
image

that’s the end of this cache working story, if we deploy the same code to another server, results are totally different.
1st time,
image

retry,
image

Why? I did a lot check, and find out the reason is simple. IT’S BECAUSE OF THE .NET FRAMEWORK VERSION.

In earlier verison of the FX, if you check the ouputCacheModule , it will cache response without checking the cookie value, that means even response has a server side cookie, it will still cache the response.
image

But for newer version, it will simply ignore the cache insert if response has cookie associated.
 image

my old version is, .4209, it never check cookie when cache response. that means you may see other people’s response (like login name?)
image
new version,.5456, it will check cookie which is more safe.
image

Hope it helps.

Wednesday, October 3, 2012

How to test RamDisk /Ram disk on centos

It turns out super easy to setup one RAM disk on centos, since linux 2.4 and beyond has the built-in support for ramdisk.

when you check the /dev/ram*, you may see a lot virtual RAM devices.
image

by default the ram device is very small, could be just less than 100Mb, so first step is always incresing the ramdisk size, to do so, append the ramdisk_size=numberofKBs to the boot config /etc/grub.conf

image

restart the server to make it refresh the changes.
now, let me create one fs first on /dev/ram1, mke2fs –m 0 /dev/ram1

image

then create one folder, and map the disk to this folder,
image

however, the ramdisk and data can’t survive the reboot, so you may put some script under rc.local to load the ramdisk and data.

run some basic testing,
image

 
Locations of visitors to this page