Transaction, multiple databases, different servers: MSDTC or any other option - asp.net

I am working on a client-server application and using LINQ to SQL to perform databases operations, 1 databases is on server and multiple clients will connect to it and there will be sync of databases records as well, Trying to manage a transaction with multiple datacontext and multiple databases but getting error on MSDTC service that it is not configured, before I go to configure I want to ask Is the MSDTC the only option? It will not be available in shared hosting then what type of hosting i should be looking for?
Any other thing I need to check before I go to MSDTC configuration? Is this service required only on server or must be configured on each client machine?

Related

Java Web application getting Cannot create PoolableConnectionFactory DB2 SQL Error: SQLCODE=-1776 for HADR configured on DB2

I have developed a web application where in i've configured two <Resource> with proper parameters in server.xml of Apache tomcat server, Using JNDI connection pool. Among two resource tags in server.xml, first tag is having details of primary server and another tag contains the details of standby server. My idea is if i dont get connection from primary for certain time, I'll switch the datasource to standby and run the query from servlet. But when I ran the code, It gave me the error Cannot create PoolableConnectionFactory (DB2 SQL Error: SQLCODE=-1776, SQLSTATE= , SQLERRMC=1, DRIVER=3.57.82)
I googled lot but cant find any concrete answer about this, but one thing was common in all i.e. HADR(Hisgh Availability Disaster Recovery) configuration of DB2 server.
Please help me out.
Generally speaking, you cannot connect to the standby database unless it assumes the primary role after the take-over.
The correct way of setting up a DB2 HADR cluster is to configure a virtual IP address in your cluster management software that gets assigned to the new primary database after the take-over; while the change remains completely transparent for client applications.
You'll need to talk to your DBAs to learn how to configure the application.
In a HADR configuration, each time the database flips from primary to standby and the standby to primary, the Server will send ClientReroute Exception to each client connected to DB2 server, So I've caught it programtically and and tried the transaction again and it succeeded.

Azure Cloud Services vs VMs for Existing Asp.Net website

I have seen variations of this question but couldn't find any that dealt with our particular scenario.
We have an existing aps.net website that links to a SQL Server database.
The database has clr user-defined types, hence it can only be hosted in Azure VM since Cloud Services don't support said types.
We initially wanted to use a vm for the database and cloud service for the front-end, but then some issues arose:
We use StateServer for storing State, but Azure doesn't support that. We would need to configure either Table storage, SQL Databases, or a Worker role dedicated to State management (a new worker role is an added cost). Table storage wouldn't be ideal due to performance. The other 2 options are preferable but they introduce cost or app-reconfiguration disadvantages.
We use SimpleMembership for user management. We would need to migrate the membership tables from our vm instance sql server to Azure's SQL Databases. This is an inconvenience as we want to keep all our tables in the same database, and splitting up the 2 may require making some code changes.
We are looking for a quick solution to have this app live as soon as possible, and at manageable cost. We are desperately trying to avoid re-factoring our code just to accommodate hosting part of the app in Azure Cloud services.
Questions:
Should we just go the VM route for hosting everything?
Is there any cost benefit in leveraging a VM instance (for sql server) and a Cloud Service instance (for the front-end)?
It seems to me every added "background process" to a Cloud Service will require a new worker role. For example, if we wanted to enable smtp for email services, this would require a new role, and hence more cost. Is this correct?
To run SQL Server with CLR etc, you'll need to run SQL Server in a Virtual Machine.
For the web tier, there are advantages to Cloud Services (web roles), as they are stateless - very easy to scale out/in without worrying about OS setup. And app setup is done through startup scripts upon bootup. If you can host your session content appropriately, the stateless model will be simpler to scale and maintain. However: If you have any type of complex installations to perform that take a while (or manual intervention), then a Virtual Machine may indeed be the better route, since you can build the VM out, and then create a master image from that VM. You'll still have OS and app maintenance issues to contend with, just as you would in an on-premises environment.
Let me correct you on your 3rd bullet regarding background processes. A cloud service's web role (or worker role) instances are merely Windows Server VM's with some scaffolding code for startup and process monitoring. You don't need a separate role for each. Feel free to run your entire app on a single web role and scale out; you'll just be scaling at a very coarse-grain level.
Some things to consider...
If you want to be cheap, you can have your web/worker role share the same code on a single machine by adding the RoleEntryPoint. Here is a post that actually shows how to do what you are trying to do with sending email:
http://blog.maartenballiauw.be/post/2012/11/12/Sending-e-mail-from-Windows-Azure.aspx
Session management is painfully slow in SQL Azure DB, I would use the Azure Cache if you can..it is fast.
SQL Server with VMs is going to cause problems for you, because you will also need to create a virtual network between that and any cloud services. This is really stupid, but if you deploy a cloud service AND a VM they communicate over the PUBLIC LOAD BALANCER causing a potential security concern and network latency. So, first you need to virtual network them (that is an extra cost)..then you also need to host a DNS server to address the SQL Server VM. Yes this is really stupid, unless you are OK with your web/worker roles communicating with your SQL Server over the internet :)
EDIT: changed "public internet" to "public load balancer" (and noted latency)
EDIT: The above information is 100% correct contrary to the comment by David below. Please read the guidance from Microsoft here:
http://msdn.microsoft.com/library/windowsazure/dn133152.aspx#scenario
DIRECTLY FROM MICROSOFT GUIDANCE speaking about cross Cloud Service communication (VM->web/worker roles):
"We recommend that you implement the first option as the connection process would not need to go through the public Internet. Therefore, it would provide a better network performance."
As of today (8/29/2013) Azure VMs and Worker/Web Roles are deployed into DIFFERENT "Cloud Services". Therefore communication between them needs to be secured via a Virtual Network that exposes private IP addresses between the instances.
To follow up on David's point below, that about adding an ACL. You are still sending packets over the internet using TDS (SQL Server protocol). That can be encrypted, but no sane architect/enterprise governance/security governance would "allow" this scenario to happen in a production environment.

Dynamically switching receive locations between database servers

Using BizTalk I need to read data from one of two databases that are hosted in Unix using ODBC.
The data is replicated between the databases and if one of the databases does not respond I need to switch to the other. There is no load balancer or anything so I need to be able to do the switch on the BizTalk server.
I was thinking of creating two receive locations, one for each database server, only one of them enabled and then have a Windows service that periodically tries to make a connection to one of the database servers and if there is an exception, call a powershell script that disables the receive location for the server that does not respond and enable the other receivelocation.
Is there a better solution for this?
I would solve this as follows:
In Biztalk create a single http receive location.
Create a windows service
In the windows service poll the first database, if it does not respond poll from the second database
Have the Biztalk service post the information to the http receive location
You need to consider what happens if you read the same data twice, once from the main database and once from the backup.

How to replicate or synchronize when databases can't have a direct connection with each other?

I have a central webservice over the internet which gets different information from different softwares and stores them in a Sql server 2008R2 database.
In addition to webservice some windows applications exist in different cities which all of them have local databses.
Now I wanna have replication between these local databases and the central database. but there is no any direct connection as like as "VPN" between local databases and central database.
so how can I do something like replication or synchronization between local databases and central database over the internet.
I'm thinking about sending local databases via web service. what is your idea?
My local databases are Sql server 2000 version
How about log shipping? You can even use FTP (FTPS--FTP over SSL, for security) to send the logs to be later on applied to the central DB. Since you have SQL 2000, you'd have to restore data to a copy of the DB in "restore" mode and then merge with central DB using SQL.
Also, from personal experience--if setting VPN is costly, you can consider using SSH. Free implementations for Windows exist, and they do a good job for secure file copy, just like FTPS.
I wouldn't use a webservice for this purpose, especially if the amount of data is large.

MSDTC Distributed Transaction Coordinator Enabling

I've a web server and a separate SQL server. I'm trying to use transaction scope to ensure that SQL queries are completed with my linq queries.
I wrap everything with this
using (TransactionScope scope = new TransactionScope())
I want to know where I need to install DTC. Do I need to install it on the IIS 7.5 box AND the SQL server? Do I need to unblock some ports? Are there any security risk in doing so?
I've setup this up once before but don't remember how. If I can't get access to DTC then is there any other way to ensure a lINQ and sql query is atomic?
I believe that this is a duplicate of Where MSDTC needs to be installed and configured.
The answer is at both endpoints participating in the transaction, but the security is such that one is outbound and the other is inbound.

Resources