Steve Morgan
Steve Morgan

Reputation: 13091

Azure Web Roles - Mixing MVC and WCF - Best Practice

I'm looking for some advice on building Azure applications that expose both an ASP.NET MVC 2 UI and WCF services.

Both are to be exposed to consumers over the Internet and the UI also consumes the WCF services.

In order to minimise operational costs for small deployments, yet be able to scale out, I want to host both the UI and the WCF services within the same Web Role. Though in other cases, I might want to deploy the WCF services to their own Web Role or Worker Role so that they can be scaled independently.

When the UI and Services are co-hosted, I'm pretty certain that I want the UI to consume instances of the Services that are hosted by the same Web Role instance. It doesn't seem to make much sense to incur the latency of the load balancer and potentially going to a different host to consume a service that's right there next to me. Do I even want to use WCF at all in this case, or consume the service classes directly? But if I do that, it precludes being able to exploit location transparency if I choose to reconfigure the application topology.

I've not been able to find much guidance on co-hosted UI and WCF services within Azure.

What patterns should I be following?

Upvotes: 0

Views: 1743

Answers (2)

Doobi
Doobi

Reputation: 4782

Consider running your Application as a Full IIS Role, and run the Services and Site as two different Sites/Roles. That way, if you need to split them at any stage it's just configuration.

Adding to IgoreK, the beauty of WCF is abstraction of implementation. If you want to run a single instance, loop back - you can even use a named pipe binding for better performance.

Should you at any point need to scale out, once again, it's just a configuration change and you can do http or even tcp through the load balancer.

Upvotes: 1

Igorek
Igorek

Reputation: 15841

I agree that using WCF interface would still be a good idea, whenever you'll need to break the configuration apart, the changes needed to get things to work should be minimal.

In WCF, you should be able to expose an internal endpoint and connect to it via 127.0.0.1 or localhost. This should bypass the crossing of data center boundary and thus, extra fees and latency.

Upvotes: 2

Related Questions