将 Amazon RDS 与 android 应用程序一起使用 [英] Using Amazon RDS with android application

查看:23
本文介绍了将 Amazon RDS 与 android 应用程序一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景
我有一个 EC2 实例,它有一个 RDS 实例(MYSQL)与之关联.我想使用 Android 应用程序在该 MYSQL 实例上执行查询.亚马逊的 Android sdk 不支持 RDS.
问题
如何将我的 android 应用程序与 RDS 实例连接?是否可以将 RDS(MYSQL) 与没有 sdk 支持的 android 应用程序一起使用?

Background
I have a EC2 instance with a RDS instance(MYSQL) associated with it. I want to use a android app to execute queries on that MYSQL instance.The Android sdk of amazon does not support RDS.
Problem
How do I connect my android app with RDS instance?Is it possible to use RDS(MYSQL) with an android application without sdk support?

推荐答案

RDS 不是数据库引擎.它是一种服务,可为您管理维护高可用性和容错数据库所需的基础设施.它支持许多不同的引擎,例如您提到的 MySQL.请阅读文档了解更多信息.

RDS is not a database engine. It's a service that manages the infrastructure for you that's required to maintain a highly available and fault tolerant database. It supports a number of different engines such as MySQL as you mentioned. Please read the docs for more information.

您需要像连接到任何 MySQL 数据库一样连接到 RDS MySQL 实例.使用支持 MySQL 的库,并使用数据库的主机名、用户名和密码.

You need to connect to your RDS MySQL instance the same way you would connect to any MySQL database. Using a library that supports MySQL, and using the hostname, username and password for your database.

但是,让电话客户端远程连接到您的数据库可能不是最好的设计.最好的办法是在 AWS 上放置一个与您的数据库连接的 REST API.

However, it's probably not the best design to have phone clients connecting to your database remotely. The best thing to do would be to put a REST API on AWS that interfaces with your database.

让 n 个用户使用您的应用从每部手机连接到您的数据库可能是一个坏主意.这意味着您需要在数据库中拥有更多功能,极大地阻碍了您的可扩展性,并且由于数据库暴露在 Internet 上而使事情变得不那么安全.借助它前面的 API,您可以构建容错性更强、可扩展性更强的解决方案.

Having n users connected to your database from each handset using your app is probably a bad idea. It means you need to have more power in your database, greatly hinders your scalability and makes things less secure as the database is exposed to the internet. With an API in front of it, you can build a much more fault tolerant, scalable and solution.

构建移动应用程序的云方式"是(在合理范围内)在云上构建您的应用程序逻辑,只需将您的客户端代码连接到您的 API.通过这种方式,您可以更轻松地扩展到更多平台(例如 IOS、Web),因为您不必为每个平台管理单独的应用程序级代码.您只需要管理与现有 API 集成的代码.

The "cloud way" to build mobile apps is to (within reason) build your application logic on the cloud and simply have your client code connect to your API. This way you can spread to more platforms (eg. IOS, Web) much more easily as you won't have to manage separate application level code for each platform. You'll just need to manage code that integrates with your already existing API.

看看这个白皮书.忽略 Web 服务器层,专注于应用服务器和数据库层.这可能是最好的设计.

Take a look at this whitepaper. Ignore the web server tier and focus on the App Server and Database tiers. This is probably the best design to go by.

这篇关于将 Amazon RDS 与 android 应用程序一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆