Saturday, 21 May 2016

Hight traffic usage on Azure Web App + Sql Server on VM

Preavious post was about trafic, and this one is not an exception. When i log in to azure portal into billing i was a bit surprices to see
Well for somebody it could be ok but for my project where i have around 3000-4000 people everyday it is too much.

The first thing I've done was writing to support, but they just confirmed that everything is right and i am actively using all what i am billed. 

By coincidence at the same time i started playing with Azure sql and it was extremaly slow, some queries were running almost twice time more than in my current setup, at that point I debug queries and was a bit of surprise how much data i am transfering from database to webapp, since in many queries i am using entityframework Include (I will start optimizin that and will write one more blog post about that) and it means it try to get everything in one request but using joins.

After that i understood that actually issue is with traffic between database and webapp, so i went to azure and start reading again about gateway and i found that all traffic which is going throw gateway is paid.  


I should never ever use gateway to connect to any server inside of azure. Gateway should be used ONLY when database machine is out of azure network.
Open end point in Azure Database VM

Connection String to Sql Server on Azure VM should look like 
",57500;Integrated Security=false;User ID=<login_name>;Password=<your_password>"
If you have same problem please vote for suggestion it would help to understand which service is using.


Lesson learned

Gateway is evil. Entityframework is evil. Each time I think Microsoft is doing something wrong it means that i fucked up somewhere :)
And last thing: Cloud are powerful, but mistakes could cost you alot.
Volodymyr Bilyachat Web Developer