Best way to deploy java application on AWS using Netbeans? - mysql

I have a publicly accessed database on RDS that works like a charm from Netbeans. I would like to deploy my Java application on AWS. What is the simplest way to do this? I will only use the application for some very basic tasks, getting used to cloud computing working on a small scale. Is EC2 my best bet and is it possible to upload apps as easily as with the Google App Engine plugin. Can I use the same jdbc driver as I use locally, and can I use JPA against the database? I would rather not use Eclipse for now as I am in a bit of a hurry and need to get this working as soon as possible.

This is a lot of questions for one question, but I'll see if I can help you out.
1. Simplest Way to deploy to AWS
If this application is as simple as you say it is, the most cost effective solution while you're getting used to AWS will be to deploy to a micro instance and take advantage of the free tier. From Amazon:
AWS Free Tier includes 750 hours of Linux and Windows Micro Instances each month for one year. To stay within the Free Tier, use only EC2 Micro instances.
The simplest way to deploy directly from Netbeans is to use the integrated Elastic Beanstalk support. This saves you from having to configure things yourself.
Another option is to launch a Ubuntu AMI and install Tomcat. Create a WAR file from your application and place it where Tomcat can find it. I suggest using the first method.
2. Is EC2 my best bet?
This is a little open ended. For a nice learning experience as you get accustomed to AWS, the free tier for EC2 is a nice platform to learn with. If your application needs to eventually scale, using EBS is a pretty simple way to manage an application. My answer is an opinion because "best bet" depends solely on the requirements of your application, but I say yes.
3. Is it possible to upload apps as easily as with the Google App Engine plugin?
For simple applications I think so. I think it's even easier if you switch to Eclipse and use the toolkit for AWS. Whether Google App Engine or AWS is easier for you will once again depend on personal preference, the application, and your requirements.
4. Can I use the same JDBC driver as I use locally?
If you're using MySQL Connector/J then yes. Read this to understand how it works with RDS.
5. Can I use JPA against the database?
Yes. You'll change the endpoint from localhost to the endpoint of your RDS instance.
6. I would rather not use Eclipse for now...
Another personal preference, but the AWS toolkit for Eclipse is very easy to use and can speed the process up a bit.

Related

Is it possible to use Elastic Beanstalk without a runtime?

I am using Elastic Beanstalk for its load-balancing and auto-scaling features. However, I am deploying a Linux binary, so I do not need .NET, Node.js, JVM, etc. My understanding is that these slow down deployments, so I would prefer not to use them at all.
I am currently using Node.js, but is it possible to use Elastic Beanstalk without any run-time?
Check out Beanstalk's custom platforms feature. Basically, custom platforms are a way of using your own Amazon Machine Image (AMI) to create Beanstalk environments with. For your purpose, it sounds like what you could do is create a base AMI, perhaps with the necessary Linux binaries installed especially if they are going to be static over time.
The advantage, of course, is that you don't need expensive runtimes/unnecessary configurations.
Here's an example of a custom platform.

Advice on approach to accessing MYSQL database from mobile app

Quick bit of advice if i may. I'm a startup company and developing a new mobile app that i intend to query and update data from a cloud MYSQL database, using a restful webservice and JSON. I am pretty new to this, but ok on the theory.
I originally thought i could use Dropbox to host the database and somehow install a Tomcat server also, to act as the http server, but i cant find anything online that says this is achievable. I've now found a temporary site heliohost.org, which offers free hosting, so i'm looking into that.
Does anyone have advice on a [low cost] longer term production cloud service for MYSQL database? And am i right that a good approach is to create a restful webservice in Eclipse and then somehow deploy that to the Tomcat server in the cloud, so that my app can then issue calls to it via the CN1 available methods.
There is quite a lot out there and much of it is self-promoting their own sites so was after some independent advice please.
Many thanks in advance.
You can't host and access an SQL server over the network from a device as access is remarkably unreliable and insecure. You will need some form of hosting. I used Linode for our online course since they are very affordable (5USD per month) but I've used AWS, Digital Ocean and others. They are all good.
You are correct that you will need to create a webservice, I used tomcat in the past but for the latest course I chose SpingBoot which is easier and more modern.
Using a mobile backend to store and retrieve data is a vast topic to discuss where different tools and services can be leveraged based on your application use cases.
However directly accessing MySQL server from your mobile client wouldn't be a recommended approach both in term of security as well as performance at scale.
Few options you can consider.
Developing the mobile backend with Amazon Mobile Hub where you can find different architectures and services. For example.
Using AWS DynamoDB as a Mobile Backend tightly controlling access permissions with AWS Cognito and DynamoDB Fine Grained Access Control.
Using Cognito Sync as a storage medium to Synchronize data from Mobile App to AWS and then using triggers to share and push data & etc.
Developing a REST API for the mobile backend using AWS Services such as API Gateway, Lambda & DynamoDB(Or Relational Databases like MySQL, Postgres SQL & etc. with RDS)

Go+MySql: how easy is to migrate to GKE (Google Cloud Container Engine)?

My project is currently hosted by an independent cloud provider.
I am using 2 Virtual Machines, with Linux:
one hosts a Go application
one hosts a MySql database
I would now like to move to the Google Cloud Platform.
Do you think does it make sense to move to Google Cointainer Engine (GKE), rather than to the Google Compute Engine (which would have the same virtual machine model (IaaS) I am using with the current provider)?
I have never used Kubernetes and Docker. How easy would it be to make the migration? Am I going to complicate my life uselessly?
How difficult is the configuration for my simple model?
I have never used Kubernetes and Docker.
Moving to a platform that you have no experience with doesn't sound like a great idea. Instead, why not start by doing some tutorials about Docker and then Kubernetes?
After that, you might try Minikube (https://kubernetes.io/docs/getting-started-guides/minikube/) locally to start writing some manifests for the components (which sound like maybe a DaemonSet or single Pod with PersistentVolume for MySQL and a Deployment for the Go application).
Once you have the pieces working locally, then it would probably make more sense to think about migrating. You would have a much better understanding of what you are getting into and if it is something you would want to undertake.

Migrate from cpanel/whm to Heroku or AWS

I have a dedicated server with WHM and cPanel installed on it.
recently I decided to move to cloud services since the dedicated server is costly and I'm not actually using any of its power, freedom and functionality.
I was considering moving to AWS or Heroku since they are less expensive, scalable and I don't need to manage the server myself.
I only have few websites on my server and I'm managing them via cPanel and WHM
I'm only using mySql database
I have also have some cron jobs setup
I use ftp to upload and maintain my websites (no git)
I was wondering if anyone could explain how I can transfer my files, databases, and domains to either AWS or Heroku.
I prefer the one that is easier and faster to migrate to.
Thanks.
If server/network management is not your strength, I would strongly advise against using AWS (even as big a proponent of AWS as I am). You absolutely must manage the servers yourselves, at least the configuration aspect (not the hardware aspect). In fact, you will find that you have to do things like set up security policies, identity access management, IP addresses, etc. that are not always that intuitive to one who is not used to working in a bit of an operations capacity.
You will also likely have to consider application architecture changes to work best with AWS services. Additionally, you will have to become accustomed to the AWS way of doings things (that starting and stopping server instances may make all your data go away and such).
If you are looking for a hands-off server approach, you might be better served looking at something like Slicehost/Rackspace.
I can't talk much to Heroku as I have only minimal experience prototyping on it. You can think of it more as an application platform. For simple applications that don't have unique traffic demands or architectural requirements, it seems a good solution for getting an application up and running with minimal server-related configuration. Again a legacy app will probably require some re-architecting to do things the Heroku way.
AWS are good but the support at Rackspace is far better and much more suited for someone like you. Rackspaces support is 24/7 and even on their online chat system you don't need to wait more than a few mins to speak to someone who actually knows what they are doing.

Java EE application deployment on Amazon EC2

We have a Java EE application (EAR file deployed on JBoss, MySQL, MongoDB) which we would like to deploy on an Amazon EC2 instance. I have several questions regarding deployment best practices.
What is the most commonly used Linux AMI which we can rely on for a robust deployment (There are so many Linux variants, and I am not sure which AMI is commonly used, is it Fedora, CentOS, Red Hat, SUSE ...)
How do we handle production upgrades (EAR file modifications or schema upgrades). Are there any tools which are available to handle this installation or rollback of these changes.
What kind of data backup capability is available for the database?
Should I rely on Amazon RDS for MySQL support?
How should I handle support for MongoDB?
This is the first time, I am hosting an web-app and would appreciate some inputs on how to manage the production instance.
I agree with Mark Robinson's answer: Use whichever Unix variant you're most comfortable with. It may pay to pick one with decent cloud support. For my site I use Ubuntu.
I have a common image which is the base of every version deploy I do. I have www.mysite.com pointing to an Elastic IP so I can decide which instance it goes to. The common image has all the software I need installed (Postgres/Postgis/Tomcat/etc) but the database and web server data folders and symlinked to Elastic Block Store (EBS) instances.
When it comes time to do a deploy I start a new instance up, freeze and snapshot the EBS volumes on production and make new volumes. I point my new instance at the new volumes and then install whatever I need to onto that. Once I've smoke tested everything successfully I can switch the Elastic IP to point to the new instance and everything keeps on going.
I'll note that I currently have the advantage where only I can modify the database; no users can. This will become a problem shortly.
If you use the XFS filesystem on top of the EBS volume then you can tell XFS to freeze the file system (so no updates happen) then call the EC2 api to snapshot the volume then unfreeze the file system. The result is that the snapshot is taken quickly and sent to S3. I have a nightly script which does this.
If RDS looks like it will suit your needs then use it. Amazon is building lots of solid tools quickly and this will ease your scalability issues if you have any.
I'm sorry, I have no idea.
Good question!
1) I would recommend going with whatever Linux variant you are most comfortable with. If you have someone who is really keen on CentOS, go with that. Once you have selected your AMI, take it and customize it by configuring how you want it. Then save that AMI as you base-layout. It will make rolling out new machines much easier and save your bacon if EC2 goes down.
2) Upgrades with EC2 can be tres cool. Instead of upgrading a live system, take your pre-configured AMI, update that and save that AMI as myAMI-1.1 (or whatever). That way, you can flip over to the new system almost instantly AND roll back to a previous version in case something breaks. You can also back-up DB instances to S3. It's cheap at about $0.10/GB/Month.
3) It depends where you are storing your DB. If you are storing it on your EC2 instance you are in trouble. The EC2 instances have no persistence storage. So if your machine crashes, you lose everything. I'm not familiar with Amazon DB system but you should also look into Elastic Block Store. It's basically an actual hard-drive you can write to. When you want to upgrade your schema, do a full DB dump to S3 and then do an upgrade of your actual schema. If something goes wrong, you can pull the previous version out of S3.
4) & 5) I have never used those so I can't help you.
What is the most commonly used Linux AMI which we can rely on for a robust deployment (There are so many Linux variants, and I am not sure which AMI is commonly used, is it Fedora, CentOS, Red Hat, SUSE ...)
How do we handle production upgrades (EAR file modifications or schema upgrades). Are there any tools which are available to handle this installation or rollback of these changes.
What kind of data backup capability is available for the database?
Should I rely on Amazon RDS for MySQL support?
How should I handle support for MongoDB?
Any Linux AMI will do the job, what you need is a JRE only. (assuming development work not required). If you need to monitor the JVM behavior then get JConsole installed.
Easiest and painless way is to SSH into the local home directory, transfer the updated class file/EAR file (depends the number of changes applied) and copy and replace into the Tomcat deployment directory, restart apache. (make sure you tested locally before upload to production).
Depends on which database you are using, if you are using MySQL then just do scheduled backup that writes to your home directory so that from time to time you could SSH in and download a copy for backup purpose.
I would not consider reply on Amazon RDS for MySQL support due to 2 reasons: MySQL is small enough and manageable, and also I would want to have total complete control of the database and why pay for more when you can do it yourself FOC?
The usage of MongoDB should be align with the purpose of your application and benefits you gain from that. I would recommend you use MongoDB for static data retrieval like state, country, area etc... where MySQL to be use for transaction data only.
If you can live with deploying your Java EE application on TomEE instead of JBoss, Boxfuse does what you want.
For you Java EE application you literally only have to execute (TomEE uses war files instead of ear files):
boxfuse run my-tomee-app-1.0.war -env=prod
This will
Create AMI containing TomEE and your application ready to boot
Create an Elastic IP or ELB
Create a security group with the correct ports defined
Create an auto-scaling group
Launch your instance(s)
Any subsequent update will be done as a zero downtime blue/green deployment.
More info: https://boxfuse.com/blog/javaee-aws