Dedicated MySql server works with app engine

2020-07-27 03:40发布

问题:

I know AppEngine application runs in a restricted "sandbox" environment so that it can access limited resources like

request execution time limit 60 sec (which is for speed optimization purpose)
read from external file but can not write ,etc

AppEngine provides a good high replication Datastore ,which is so good to store data but it is hard to mange number of quires to perform simple operation like insert, update, delete and update as it uses NoSql(basically jpa and jdo).

Because of this we decide to go with Mysql,I know google itself provide cloud sql instance which uses Mysql5.6 ,I searched alot on SO and in some post I found that it is possible with some restriction while some post says it is not possible because of limitation of sandbox environment,so it is confusing .

During development one can use local mysql instance as detail provide on this link ,but we want to use External mysql instance which is hosted on ourserver

It possible use Dedicated (External/Local) MySql server with app engine(for production not for development)?

thanks in advance!!!!!!

回答1:

Google App Engine has a socket API that allows outbound sockets for paid apps, so it is possible to use an external MySQL service. To do this, follow the instructions at the link you provide, but always use the com.mysql.jdbc.Driver JDBC driver, and a URL like jdbc:mysql://your_external_mysql_server:3306/database_name?user=your_user&password=1234. Ensure your external MySQL server has port 3306 open.

As mentioned by others this may not be advisable as it will have substantially worse performance that the Datastore or Google Cloud SQL. You will also lose the reliability and scaling that Google App Engine brings. Moreover hosting a dedicated MySQL instance and paying for bandwidth to it is likely to end up more expensive than simply using Datastore or Cloud SQL.