I have a mobile app on android that needs to send small amounts of data (id, lat and long coords) every 30 seconds to be stored in a SQL Server databa开发者_如何学Cse sitting on an amazon ec2 instance. As an example usage, say that this app has 500 current users all sending data every 30 seconds. For proof of concept I created a windows service in c# running on the database server which listens for connections on a specific tcp port; it threads, and writes the data to the database. Now this works for the 5 users I tested with but I know there are better ways and I especially do not want the insert statements to be done with a program running on the database server. So my question is, what is the correct way to handle repetitive data streams from a large user base that scales in a manageable way. I have read information regarding implementing webservices to do this but I am not sure if that is the correct solution.
Thank you for any information.
Using a web service approach is definitely more scalable than using a Windows service. If your usage grows enough to justify it, it will be also be easier to deploy your web service in a new EC2 instance (or to multiple load-balanced instances) instead of using a windows service which shares resources with your DB instance. It is also much more manageable, especially under AWS, where you can scale your infrastructure with a few clicks.
Also, under a web service (or a web application, if you prefer), it is easier to set up access control and to take other preventive security measures.
精彩评论