Click to See Complete Forum and Search --> : 3-tier design and scalability?
janis
Apr 24th, 2003, 03:32 AM
Ok, there is what I need:
I need to build 3-tier(n-tier) application where the main issue is scalability. What that mean? Presentation layer is on many machines in lan, business layer is on one(two or more) servers, also data access layer is on server. My problem is: if some servers, where lies business objects(layer), is to loaded I need to move some business objects to another(new) server without changing anything in presentation layer. My question is now to manage communication between presentation and business layer? Obviously, I can't use 'add reference' in pres. layer, because I don't know where business object will be (on which server).
I think to solve that with remoting, but again (I think) I must know exactly location of server, what I don't know because it may be one, two or more servers.
What you think, what is solution?
regard j
shutty
Apr 24th, 2003, 05:59 AM
Originally posted by janis
Obviously, I can't use 'add reference' in pres. layer, because I don't know where business object will be (on which server).
The business layer and GUI layer should always be independant, and should never interact directly. You should have a Controller class sitting between the two that handles all the communication.
As for remoting, can't help you there I'm afraid. Have a look at the Factory Design Patten as this would enable you to implement code that react to runtime situations.
PT Exorcist
Apr 24th, 2003, 11:30 AM
My question is now to manage communication between presentation and business layer? Obviously, I can't use 'add reference' in pres. layer, because I don't know where business object will be (on which server). not sure but shouldn't u use reflection? the ability to invoke methods at runtime? u can do reflection to assemblys in ur own computer or in the internet if u know it's internet address
shutty
Apr 24th, 2003, 11:32 AM
Originally posted by PT Exorcist
not sure but shouldn't u use reflection? the ability to invoke methods at runtime? u can do reflection to assemblys in ur own computer or in the internet if u know it's internet address
that's a valid point, but if he doesn't know where the objects are how can he reflect them?
PT Exorcist
Apr 24th, 2003, 11:34 AM
but then what's the point? he can't make magic! in anyway he will have to know where the object will be!
shutty
Apr 24th, 2003, 11:37 AM
Maybe remoting is the answer anyone know anything about it?
Edneeis
Apr 24th, 2003, 11:42 AM
Remoting uses a URL type address with an IP and Port. You can remote object via a LAN and the Internet. If you expect to use some kind of callbacks/events with remoting and a NAT router is involved than beware you will have some trouble. If you can post the files to a URL then you could change the physical location anytime as long as the URL stays the same. If that is the case then you can use the LoadFrom method of the Assembly object to load a remote Assembly from the URL. I believe it downloads a local copy and runs it, this is without using remoting. Also if you use remoting then the clients will need at least a shared interface stored locally for it to work.
Lethal
Apr 24th, 2003, 12:24 PM
The business layer and GUI layer should always be independant, and should never interact directly. You should have a Controller class sitting between the two that handles all the communication.
How does the controller class actually contribute to the architecutre? It seems if you moved your UI from a Win32 interface to a web based interface, this would just be one more component to manage. What is the negative impact of just having your presentation tier communicate directly with the business/validation layer.
hellswraith
Apr 24th, 2003, 01:49 PM
Set a point (DB somewhere) where all servers are registered with. The controller object will request the available servers from this point. That will be the only known point that must stay. From then on, when you add new business machines, you just register that machines path in the point established. The controller object will gather the different paths from the point(DB) and handle the calls by redirecting them to the different business machines. This is basic load balancing. I even think that MS has built these types of apps for you so you don't have to do the work.
http://www.microsoft.com/technet/treeview/default.asp?url=/technet/prodtechnol/windowsserver2003/proddocs/server/wmserver/loadbalancing.asp
janis
Apr 25th, 2003, 03:45 AM
Yea, I think that's right direction.
regard j
shutty
Apr 25th, 2003, 04:58 AM
Originally posted by Lethal
What is the negative impact of just having your presentation tier communicate directly with the business/validation layer.
Have a read up on the Model-View-Controller (MVC) method it will expain the positive & negative impacts far better than I can here. Basically it is good design practice to keep your business code and GUI code seperate. It is something I have done and benefited from greatly.
Quote from Design Patterns by Gamma, Helm, Johnson and Vlissides:
The Model is the appication object, the View is it's screen presentation, and the Controller defines the way the user interface reacts to user input. Before MVC, user interface designs tended to lump these objects together. MVC decouples them to increase flexibility and reuse.
NighaŽe
Apr 25th, 2003, 11:22 AM
Hi,
i have a same kind of sollution in a data production system.
The products is a client server sollution with multiple server / winservices, remoting, MSMQ, reflection, interops, COM+, MTS, ....
Goals of the project:
Consolidate all european departments (we do dataproduction on large databases) to 1 central system and location.
The system must be fully PnP (this means extra features can be added without rebooting the system).
So it must be scalable, secure and fully plugable.
What i did is building a kind of jobtrack system, job processors, some pre processors and a delivery system. All of them run as windows services.
When a job comes in (MSMQ) the jobtrack service will check the job processing script and forward it to a free job processor in the lan. This is done by create performance counters on the processors and reading the performance counters over lan (just change machine "." to the server name)
The available servers for the jobtrack service are registered into the windows register. (trough the manager application you can add / remove servers)
The Job Processor service is a very simple service using remoting.
Each process like a sql download is started from a COM+ component. So first the processor looks what he needs to process and forwards the process to another computer containing the component. (application servers). These components are called by the CHost service thats use reflection of external COM+ dll on the server.
Some components that need much resources are installed on separated server to increase performance. Also all components are registered in the winregister.
Once a job i completed its send back to the delivery que in the MSMQ.
The the jobtrack system picks up the job again and fill forwared it using remoting again to the delivery system that can deliver using mail, ftp upload and http post.
===
The following example show how i did the interop.
This class is prepared on the jobprocessor and processed by the CHost service using remoting.
The sample simply loads a simple query from the northwind database on sql server. The parameters are now set in the code, but need to be readed from the job processing script.
These are the parameters finaly send to the COM+ component.
args(0) = "SQLCommand" <<< string command.
args(1) = "TestData" <<< output dataset name
args(2) = objParam <<< command parameters (set in script below)
Afterward the Load assembly / module and class are loaded.
The assembly is the full path to the assembly.
The module, is the dll name (in case you link 2 dlls using al)
The class is the class name including the namespace.
In my case the Method is static cause i use a kind of template (using a interface) with only 1 public function and thats run.
The rest is processed inside the component using the command string and parameters.
Protected Const CMD_SQLCOMMAND As String = "SQLCommand"
Protected Const KEY_SQLCOMMAND_CONNECTIONSTRING As String = "ConnectionString"
Protected Const KEY_SQLCOMMAND_COMMANDSTRING As String = "CommandString"
Sub Test()
Dim objAssembly As [Assembly]
Dim objModule As [Module]
Dim objClass As Type
Dim objMethod As MethodInfo
Dim objParam() As object
'// Load Assembly
objAssembly = [Assembly].LoadFrom("D:\Temp\vs.net\ClassLibrary3\Bin\NP.Test.dll")
'// Load Module
objModule = objAssembly.GetModule("NP.Test.dll")
'// Load Class
objClass = objModule.GetType("NP.Test.dpsSQL")
'// Load Method
objMethod = objClass.GetMethod("Run")
'// Load Parameters
ReDim Preserve objParam(1)
objParam(0) = "Server=NPDC001;UID=sa;PWD=***;Database=Northwind"
objParam(1) = "SELECT * FROM Customers"
Dim obj As Object = Nothing
Dim args(2) As Object
args(0) = "SQLCommand"
args(1) = "TestData"
args(2) = objParam
Try
Dim param As ParameterInfo() = objMethod.GetParameters()
' Can we convert the strings to the right types?
Dim newArgs(args.Length - 1) As Object
Dim index As Integer
For index = 0 To args.Length - 1
Try
Console.WriteLine(param(index).Name)
newArgs(index) = Convert.ChangeType(args(index), param(index).ParameterType)
Catch e As Exception
Throw New Exception(objMethod.DeclaringType.ToString() & "." & objMethod.Name & ": Parameter Conversion Failed", e)
End Try
Next index
' Does the type need an instance?
Dim instance As Object = Nothing
If Not objMethod.IsStatic Then
instance = Activator.CreateInstance(objClass)
End If
' Invoke the method
obj = objMethod.Invoke(instance, newArgs)
Catch exp As Exception
Console.WriteLine(exp.Message)
Console.WriteLine(">> " & exp.InnerException.Message)
End Try
If Not obj Is Nothing Then
Console.WriteLine(obj)
Return
End If
End Sub
I hope this helps you. If you want the sample of the remoting script i can post it later (dont have it at home)
:) Greets Nightmare :)
TheExtreme
Apr 29th, 2003, 09:00 AM
The solution you want is to use COM+ Services / System.EnterpriseServices with component load balancing. write the app for COM+ then let CLB do the rest of the work for you.
Gurus@WinMgmt.com
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.