Friday, February 24, 2012

client/server processing

I'm going through a set of MS e-learning classes and am confused about where the processing occurs. In general, I thought that all the processing occurred on the Server once the client made a request. This e-learning confuses me as it says that the processing is spread out between the client and the server. What is the correct answer?

thx,

Kat

I'll try to answer your question with some examples. If there still seems to be a conflict with the e-learning, you might have to give some context.

If you think about a SQL query, your statement would be the most correct. The client sends the query to the server. The server interprets the query and returns the results to the client. Turning the statement into a result set could be considered the "processing" and that was done on the server. In practice, something more must be done with the result set for it to be useful. This could be as simple as formatting the result set into a grid or text representation. All that work is done on the client.

Another example could be a web page. The browser makes a request to the Web server, which might in turn make a request to a database server. The query would be handled as above with the Web server playing the role of the database server's client. The Web server formats the results into HTML which is returned to the browser. The browser is still responsible for interpreting the HTML and displaying it properly.

To sum up, in a client/server architecture the processing is spread between the client and server with each piece doing the part that it is most suited for.

Hope that helps.

|||

Thank you, it is making more sense. I am speaking specifically about SQL Server procressing. How do I know what processing is done by the SQL Server itself and the workstation which runs an sql query, starts off a stored procedure, runs a batch statement, does transaction processing, or runs OLAP as examples?

thx,

Kat

|||

In terms of Sql Server, the processing is all done on the server. The client only has to format results.

Consider Query Analyzer. You enter a T-Sql query and request that it be executed. Query Analyzer sends the text you typed in to the Server. So, checking for proper syntax, parsing, optimization, data retrieval, sorting all is done on the server. Query Analyzer gets results back, much as a .Net application would.

A stored procedure is exactly the same. The code to define the stored procedure is sent to the server. It is parsed and pre-compiled and stored. When a request is made to execute the stored procedure, that text is sent to the server. It is checked for proper syntax, etc. and the stored procedure executes completely on the server. Any results are sent back.

The only time that processing is done on the client is when DataSets are used. But, the data must first be retrieved from the Server. It is fairly clear when the data has been put into the DataSet. Once there, actions such as making relations between datatables and defining computed columns is on the client.

The DataAdapter might be a little confusing, but all it does is use the queries assigned to it to make repeated database requests.

Another area that can cause confusion is optimistic concurrency. In this case the client and the server work together. Optimistic Concurrency works by including old values in the query that does updates or deletions. The database server does not know what is going on. It just knows that there was a query that effected no rows. The client uses that information to infer that the record was changed behind the scenes.

As far as I know, OLAP uses standard SQL queries so it is done on the server.

One way to get a feel for these things is to look at the low-level API.

No comments:

Post a Comment