Wednesday, 30 April 2008

elastic experience

Been playing with Amazon's web services, EC2 and S3.

EC2, Elastic Computing Cloud, is really nice. In a nutshell, it allows you to create servers on the fly as and when you need it.

My initial impression before using it was that is would be very good for high load, performance intensive applications for larger corporations or research. And not for my use; low to none performance, tiny web sites and web apps, which are mostly used by just me.

The main reason was the cost of running one 24/7 is costly with amazon pricing, especially as it would be idle most of the time. At most I get 500 web site visitors a day, thats only 1 every few minutes.

But after playing around with EC2, I have realised it can also be very usefull for my meagre usage. Initially it looked a conveluted way of creating and accessing EC2 and S3. But the starter guide was actually quite easy to follow. And then the firefox extensions for both makes admin very easy.

I run a subversion server on my normal server for my code, websites, documents etc. But its does not need to be online 24/7. I can just bring up an EC2 AIM instance for a little while, or even for the daytime hours.

I also use my current server to run test apps, which only I use. They do not need to be up for very long. EC2 will be fine.

The main cost will be the 24/7 hosting of my static web sites. If I run one, I might as well run them all on the same instance. But I worked out the costs is on par the ISP is charging for my co-location server. However it's costs are shared with others, which I may not be able to do with EC2.

So now Im moving from one physical server doing everything(including crashing and being down for long periods), to several dynamic instances with at least one permanent. Will keep a look at costs to see how much more this way is costing.

Will have to write and create some routines to persist to S3 some of the data of the instances. This looked a pain initially, but I think it is just a period of adaption before it will be acceptable.

One thing Im not sure I can move to EC2 is my email server. But google apps is handling well some of my domains, I might just convince myself to move it all to it.

Ps. The one odd, funny thing, but to be aware of with EC2, is that after you have terminated your instances, try after awhile the ip again in a browser. I have gotten other people's instances whom have been handed the IP, but often their websites are in their initial install state. So Ive seen default admin pages for CSM apps(ie with default passwords as well) etc being exposed to anyone before the actual owner logs in and changes settings. Remember you can be in the opposite situation as well.

Sunday, 27 April 2008


My server keeps crashing. No idea why. And I cant physically get to it anymore. It feels really frustrating.... :(

It has been up faultlessly for more than two years so suppose ive been spoilt.

And the other people I share the server can neither get to the server easily, but at least they still work in the same country as the ISP. But it means days delay between reboots. And then some hours of searching for why it crashes before its gone again.

Things is, it worked faultlessly when we removed it from the isp and ran it for a few days at someones house. But in the ISP it dies within a day.

If it is hardware, my main suspect is always the powersupply. But I cant remember what the specs where......

Tuesday, 22 April 2008

No single default persistence unit defined

If you getting nowhere with this type of problem:

Using spring and jpa, and you get this error:

No single default persistence unit defined in {classpath*:META-INF/persistence.xml}

And you DO have a persistence.xml in your classpath.

Then the cause is simple.

You may have other persistence.xml files as well in your lib/jars.

Solution, add your persistenceUnitName to entityManager bean.

<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="persistenceUnitName" value="blahblahYourName" />

which matches the one in your persistence.xml

<persistence-unit name="blahblahYourName">