SQL Azure vs WCF Performance
I've se开发者_StackOverflowen a lot of benchmarks on Azure performance, but I'm wondering if anyone knows of/has done a comparison to see which of the following scenarios performs better for a thick client application.
Connects to WCF services for data access that are running in the cloud and connect to a local SQL database. For examples sake, let's say it's a WCF Data Service with an underlying Entity Framework model that connects to a SQL database on Azure.
Connects directly to the SQL Azure instance from the client. For examples sake, let's say it's the same queries and Entity Framework model as above, but connecting directly to the SQL Azure instance instead of through the WCF Data Service.
Thanks.
I would definitely recommend that you go with the WCF+SQL Azure
One of the basic ideas behind SOA is to build chunky rather than chatty interfaces. This is especially true when hosting in the cloud as your client is not close to the data.
If you have complex business objects to populate you may have to run a number of queries. By using WCF Services to talk to SQL Azure then you can run all those queries within the Azure environment and keep the Internet round trips to a minimum.
Of course it costs more to do it this way, but it scales better as the services layer can be scaled out.
There are a number of big advantages to doing this.
- Separation between client and database (Data structure can be updated without changing client).
- As a consequence of 1 if you need to shard the database you can.
- If you need to upgrade later to SQL Azure Federations (When it 's out) then you can.
- You have an easy hook if you want to use Azure Caching.
- Security(1) Your database stays behind the firewall.
- Security(2) You can authenticate every request rather than simply on connection.
- Security(3) If you are dealing with documents/blob storage then you don't need to make your storage account keys available to the client.
I am managing a number of reasonably large multi-tenanted systems with your the WCF+SQL Azure architecture on the back end and it works fantastically well.
SQL Azure on its own does work well over the web to the point where I am even happy to run my Dev databases in azure but I don't think it's a good choice for a production app.
Hope this helps.
I haven't done the benchmarks myself if we look at this logically.
You're asking which is faster SQL Azure(S) + Entity Framework (EF) + WCF
or S + EF
.
If we presume that the data being transferred from the cloud in the form of query parameters and results sets is roughly the same size (which it probably is unless the WCF service is using SOAP or other XML format, it which case WCF will definitely be transferring more data) then only only difference between these two scenarios is the processing the WCF does in the middle. While that communication is usually pretty small, it's not equal to zero, so the direct approach should be quicker.
Unrelated to speed, I don't think it would be worth the effort to create a web/worker role just to host this WCF service. For a 10GB database you'd be more than doubling the cost of hosting the database and adding a level of complexity that doesn't seem to be justified.
If you do already have a role that it makes sense to host WCF on, then this could make sense from a design perspective and I don't think it would affect performance too much (depending on transport method and security used).
There are several aspects to this:
- Performance
- Cost
- Security
On Performance your first option has an extra hop, so it will be slower. But if you have a really complicated query, the difference between the two will be very small measure compared with the total time.
On Cost your first option will require an extra instance to run the WCF services therefore more cost.
On Security your second option opens a port to the database from the internet, therefore less secure.
精彩评论