I’m working on a new infrastructure for a DataSnap server. I need some basic stuff, pretty straightforward in the most technologies, but not very common for delphi servers, like automated distributed deploys, load balancing, auto scaling, failover.
The AWS documentation says that Elastic Beanstalk only supports some technologies (Ruby, .NET, Java, Nodejs, etc), in fact, some languages, which is weird. However, the .NET support includes IIS applications. So, if we can generate a ISAPI DataSnap server, it will work.
It is surprisingly simple. Probably takes less than 5 minutes. We only need to do this:
Create a WebDeploy package
Create the Elastic Beanstalk application
Creating a Web Deploy package
I created a github repository (RobertoSchneiders/webdeploy-isapi-package) with a web deploy package that contains an ISAPI Datasnap Server, you can use as an example or starting point.
The other option is to configure your ISAPI on your local IIS and then use the Export Application to generate the package. You only have to make sure to rename the “Parameter 1” to “IIS Web Application Name” on the second page of the wizard (References from IIS 7.5, may be different on 8.5).
You will have to add some ebextensions, to allow IIS to run ISAPI applications. More details on the github repository readme.
Creating the application on AWS Elastic Beanstalk
I will show some settings step by step, only for those who do not know the AWS EB have an idea, but it’s very simple.
On AWS Elastic Beanstalk console page:
Create New Application -> Inform the name
Create web server on thee New Environment page
On predefined configuration select the IIS platform You can choose if you want Load balancing and Auto Scaling or a Single Instance.
Upload your WebDeploy package (You can configure automated deploys via AWS S3)
In the permissions page you have to inform some roles, like this:If this is the first time you are using EB you have to create them, but not worry, you can use the default values, that the wizard will sugest to you. You can not use the same roles for Instance and Service, it will not work.
And that’s it. Now you have a Datasnap application running on a Windows Server 2012 Core, IIS 8.5, load balancer, auto scaling, failover, almost zero downtime deploy.
Some important details
For the failover work properly you must configure a Health Check URL on Configuration Details page.
You probably will have to customize the Auto Scaling rules according to resource consumption of your application.
With Auto Scaling you will have more then one instance running, so, you must be aware of the context.
If you want to use the HTTP Callbacks you will have to use the Sticky Sessions on the load balancer.
You can delegate the SSL for the load balancer and remove that responsability from the datasnap server, it is very simple to configure. The Elastic Load Balancer also supports cyphers.
Conclusion
It is possible to have a modern infrastructure even if you are dealing with Datasnap, and this is amazing. I hope you enjoyed and that has been helpful.
I have not shown how to configure automated deploy on this post, but I hope to do so in the future.