ichi.co.uk

Microsoft AppFabric vs Redis (Windows port)

The traffic of our football news syndicating website (Kick News) has been steadily growing a lot since it launched. When we redeveloped it a couple of years ago, we used an in-process cache, by creating an IQueryable extension method that uses an md5 hash of the underlying SQL query as the key. This worked reasonably well, but has it’s obvious problems, such as the caches needing to be refilled when the app pool recycles or when the server is restarted. On our busy site, this means we had to wait until the caches are full before we serve any requests or it would overload our database server, which is unacceptable. Before the site gets any busier we’re going to move to an out-of-process cache and the are 3 main options we’ve considered are Redis, Memcached and Windows Server AppFabric (there are other options however, such as Coherence). There is already quite a lot of info on Redis vs Memcached, so I won’t go into that here, but I was curious as to how AppFabric performed against Redis. 

This is an extremely limited and unscientific test, however all I was looking for was an indication and couldn’t find any data elsewhere. I used Dusan Majkic’s Windows port of Redis and the ServiceStack.Redis C# Client Library, so results might be different if I used the native version of Redis, but not enough for me to care about in this little test.

Setting up AppFabric on my test machine was a breeze and Scott Hanselman has an easy to follow guide here. To run the test, I created an ASP.Net MVC 3 project and used a System.Diagnostics.Stopwatch() to time the execution of putting and retrieving 1,000 4 byte strings and then the same with a byte array of a 115KB image. I ran the test 6 times, resetting everything in between runs and then averaged the results. There was a some variation in each run (the 4 byte string tests where all roughly the same), but I think this gives me a pretty good idea of what I wanted to know.

Set 1,000 4 byte strings:
AppFabric: 918 ms
Redis: 240 ms

Get 1,000 4 byte strings:
AppFabric: 587 ms
Redis: 137 ms

Set 1,000 115 KB byte arrays:
AppFabric: 11,195 ms
Redis: 15,812 ms

Get 1,000 115 KB byte arrays:
AppFabric: 11,976 ms
Redis: 7,163 ms

I forgot to mark them, but 1 is set and 2 is get. The conclusion I draw from this is that Redis is as fast as everyone says it is (I don’t believe AppFabric is any kind of slouch). I’m not sure why Redis ended up slower in the larger byte array set test, but there was one run when it was quite a lot slower, which would have dragged it’s average down a bit. To answer the question properly, we’d need a much better benchmarking test, but I think it’s safe to say that overall Redis is quite a lot faster overall than AppFabric, however AppFabric is very easy to setup and cluster. I think we’re going to go with Redis on a couple of dedicated Debian VMs over Memcached or AppFabric, but I think all would be a massive improvement for us over our existing in-process caching. 

First look: Bitcasa Infinite Storage

I just got an invite to Bitcasa today, so I used it to sign up and get my infinite storage and got 10 invites to share (below). 

Installed fine on both OSX (beta) and Windows (alpha), although I’d say the Windows installer needs cleaning up a bit, as it launches two separate installers (MS C++ redist and Doken).

To upload your files to Bitcasa, you just right click a folder and select “Services > Cloudify this” on OSX:

or Bitcasa Cloudify on Windows:

They currently have a fairly rudimentary but functional web portal to access your files and the client looks (on OSX at least) like the below screenshot.

Getting Calculator.app out, I can see that this is about 3.33 Mbps, which isn’t bad since I’m uploading from the UK to the US east coast (I have 10 Mbps upstream bandwidth on my cable connection).

I read here that they’re going to charge $10 per month once the beta is over. If it works OK and they don’t have a security faux pas, like Dropbox, I’m totally happy to pay that for unlimited cloud storage. 

This link should work for the first 10 people that use it, after that it will just add people to the waiting list, so I’ll try to keep an eye on it and remove it once they’re all gone….

Invites here.

Update (12 Feb UTC): 2 invites left.

Adding a minimum length constraint in SQL Server

This might seem fairly obvious, but using Len(ColumnName) can give unexpected results, as it returns the number of characters in a string instead of the number of bytes, i.e. it trims the text before it counts the characters. More details on that here.

To create a minimum length constraint, open up your table, right click Constraints and select New Constraint. Then enter something like…

(datalength([YourColumn])>(2))

SQL Server 2005 maintenance plan fails and service pack fail to install

I needed to setup a maintenance plan for a client to backup their databases and remove backups older than 4 weeks. They run SQL Server 2005, so I created the maintenance plan with a Back Up Database Task and a Maintenance Cleanup Task to remove the old backups, which is straightforward enough. When I tried to test it however I got the error: “Unable to start execution of step 1 (reason: line(1): Syntax error). The step failed.” 

I had a quick look at the version of the server and it was 9.0.1399 (SQL Server 2005 RTM!!!). So I downloaded SP4 and went to install it, however when it gave me the options for the components to update, it wouldn’t let me check Database Services and when I selected it, the details box said “This update requires language ENU. The language for product instance MSSQLSERVER is . Download the update for language .”

Now, I know this particular server hosts a lot of Sage 200 databases as well as the database for my app. The guy that setup Sage 200 changed the language to be British English because for some reason Sage don’t use ISO date formatting (yyyyMMdd) and instead use UK style dates (ddMMyyyy). 

The fix for this was to change the language values for SQL Server in the registry.

Stop the SQL Server services via services.msc, fire up regedit.exe and write down the current decimal value for the Language value in the following two keys. 

HKLM\Software\Microsoft\Microsoft SQL Server\MSSQL.1\setup

HKLM\Software\Microsoft\Microsoft SQL Server\MSSQL.1\MSSQLServer\CurrentVersion

Now change them both to 1033 decimal (which is US English) and re-run SP4 setup, which should now allow you to upgrade the Database Services component. Once you’re upgraded return the registry values to their original settings.

I actually ran into another problem after this (Error Code: 0x80070534 (1332) Windows Error Text: No mapping between account names and security IDs was done.), which I had to dig around in the SP4 install log for, but it turned out quite easy to fix by deleting some registry keys and letting SP4 setup recreate them.

[Flash 9 is required to listen to audio.]
'Upular' (Virtual 3D)

1,166,510 plays

'Upular' (Virtual 3D)

hamburglr:

First, go grab some headphones. The best ones you’ve got. If the best ones you’ve got are these suckers (or something similar), you should really go buy new ones, but use the best you’ve got for right now.

Take a break from whatever you’re doing for 2 minutes and listen, but just listen to the whole thing, even if you have to multi-task.

Headphones on? Ok. Good.

Now, press play.


“Upular (3D Audio Version)” - Pogo

Source SoundCloud / PogoMix

Reblogged from HAMBURGLR

[Flash 9 is required to listen to audio.]
Winter Drum & Bass Mix 2011 - iamichi

311 plays

Winter Drum & Bass Mix 2011

by iamichi
album Winter Drum & Bass Mix 2011

http://soundcloud.com/iamichi/winter-mix-2011

Creating an ‘elite’ highly anonymous proxy with Squid on Debian

This is a simple guide on how to setup a Debian VM for use as an ‘elite’ web proxy. There are 3 types of web proxy server and what type they are basically just comes down to which HTTP Headers they include about who you are.

Transparent Proxy

REMOTE_ADDR: Proxy IP address
HTTP_VIA: Proxy IP address/hostname and details - e.g. 1.1 proxy1.mydomain.net:3128 (squid/2.7.STABLE9)
HTTP_X_FORWARDED_FOR: Your real IP address

Anonymous Proxy

REMOTE_ADDR: Proxy IP address
HTTP_VIA:   Proxy IP address/hostname and details - e.g. 1.1 proxy1.mydomain.net:3128 (squid/2.7.STABLE9) 
HTTP_X_FORWARDED_FOR: blank

Elite Proxy

REMOTE_ADDR: Proxy IP address
HTTP_VIA: blank
HTTP_X_FORWARDED_FOR: blank

Below I’ll detail the extra configuration params you need to get squid into ‘elite’ mode.

I like Debian mainly because it’s what I know best and has a very good reputation. Ubuntu is updated every 6 months and Debian is updated when it’s ready, which makes me trust it more. Also Ubuntu requires 128MB of RAM and Debian only 64MB.

I needed to do few of these quickly, so I just did it on a Windows Server with Hyper-V as it was convenient. First I created a new VM in Hyper-V with 96MB Memory, mounted debian-6.0.2.1-amd64-netinst.iso, but if you are using Hyper-V like me, before starting the VM, you need to go to the VM Settings, remove the Network Adapter and add a Legacy Network Adapter, which should be connected to the Virtual Network as Debian has a driver for this interface already.

I am not going to walk you through all the steps of installing Debian, as it’s straightforward enough and guides already exist. You’ll probably want to select the option to install a SSH server during setup and once it’s complete, SSH or console in and enter:

aptitude update
aptitude upgrade
apt-get update
apt-get install squid

That will update and install Squid (it installed 2.7.STABLE9-2.1 for me), so now we need to configure it. You might also want to secure your install a bit more than it is at this point as well, such as setup iptables, Fail2ban, disable root logins, etc. but I won’t go into that here. Squid should work as a proxy out of the box on port 3128 but it will identify itself as a proxy, so let’s change that. The Squid config file that comes with it is almost 5000 lines and well documented so I suggest you backup the original and create a new one with just the settings we need, so that we keep it simple.

cd /etc/squid
sudo mv squid.conf  squid.conf.orig
nano squid.conf

That will open the nano text editor, creating a new config file. Squid has some options for access control, that is, what IP addresses are allowed to use it. For more info on this, check here. For me, I wanted my LAN to have access and also my VPN clients, but you might want LAN IP addresses or to allow anyone to connect. Enter this into nano…

acl all src all
cache deny all
http_port 3128 transparent
acl privatenet src 172.16.0.0/255.255.254.0
acl vpnnet src 10.101.10.0/255.255.255.0
http_access allow privatenet
http_access allow vpnnet
forwarded_for off
visible_hostname proxy1.mydomain.net

That allows all IP address 172.16.0.0/23 and 10.101.10.0/24 to connect to the proxy. This setup gives us an anonymous proxy which will show as what you set in visible_hostname, however we want an ‘elite’ proxy, so also add…

header_access Via deny all
header_access Forwarded-For deny all
header_access X-Forwarded-For deny all

Exit nano with ctrl-x and save the config file when prompted, now restart Squid with…

/etc/init.d/squid restart

Once you’re done, to test it add your proxy server to Firefox

and you can check your proxy here or here.

I hope that helps someone.