Newbie: Network Sockets and Ports

B

boanator

Can someone tell me if there is a problem with this set up?
I have a server that is listening to a single port (port 6070).
Requests are made to the server at port(6070) and processed. Clients
will send requests to the server for several different services. Let's
say there are 10 different services managed by this server.
From my understanding, each request will setup a new socket for
communication and continue to listen on port 6070 for new client
requests.

Even though each client request creates a new socket for communication,
will it slow things down if all of these requests are going through the
same port 6070, synchronous or not?

Also, will it speed things up if I create a new server for each
service?
Say:
service 1 listens to port: 6070
service 2 listens to port: 6071
service 3 listens to port: 6072
....

Thanks in advance for any advice?
 
M

Matt Humphrey

Can someone tell me if there is a problem with this set up?
I have a server that is listening to a single port (port 6070).
Requests are made to the server at port(6070) and processed. Clients
will send requests to the server for several different services. Let's
say there are 10 different services managed by this server.

communication and continue to listen on port 6070 for new client
requests.

I can't say empirically whether there is a performance difference for
requests on the same port. I would not expect to find any performance
differences because TCP connections are uniquely identified by their client
ip, the client port, the server ip and the server port. Even requests from
the same client to the same server and same server port will still be
completely separate because the client port numbers will be different.
Even though each client request creates a new socket for communication,
will it slow things down if all of these requests are going through the
same port 6070, synchronous or not?

No. The requests aren't being processed by the port--rather they are handled
by each socket independently, usually in a separate thread which is arranged
to take advantage of potential request parallelism.
Also, will it speed things up if I create a new server for each
service?
Say:
service 1 listens to port: 6070
service 2 listens to port: 6071
service 3 listens to port: 6072

Aside from the time your server requires to parse the request itself, I
can't see any reason that using different port numbers would be
significantly (or even measurably) faster. Are you considering a
high-performance application and have you done profiling that shows that
socket connection time is a problem? This issue doesn't seem to be a
problem for the very large scale web servers that have to serve up
documents, images, functionality (servlets, etc.)

Cheers,
Matt Humphrey (e-mail address removed) http://www.iviz.com/
 
S

Steve Horsley

Can someone tell me if there is a problem with this set up?
I have a server that is listening to a single port (port 6070).
Requests are made to the server at port(6070) and processed. Clients
will send requests to the server for several different services. Let's
say there are 10 different services managed by this server.

I don't see any problem with this arrangement, provided that the
server can distinguish between the different types of requests.
communication and continue to listen on port 6070 for new client
requests.

From the server software's point of view, each incoming
connection causes the ServerSocket to return a new Socket from
its accept() method. The ServerSocket continues to listen for new
calls.

You could simply process one request over each new connection and
then close it, or you may choose to support multiple requests
over one connection, perhaps even allowing a second request to be
sent before the first has been answered. The trade-off is really
efficiency vs complexity. It is probably easiest to start by
handling single requests.
Even though each client request creates a new socket for communication,
will it slow things down if all of these requests are going through the
same port 6070, synchronous or not?

I don't think the port number is relevant. Getting your threading
right, so you can continue to process some requests while others
are waiting for database or disk I/O is the important thing. This
used to be done by using one thread per connection/request, but
the recent java.nio packages allow one thread to service many
connections efficiently by looking to see which ones have data
ready, and this can scale to larger numbers of concurrent requests.
Also, will it speed things up if I create a new server for each
service?
Say:
service 1 listens to port: 6070
service 2 listens to port: 6071
service 3 listens to port: 6072

I don't see why it should. This decision should be based on other
considerations such as ease of implementation, support,
enhancement, flexibility etc.
Thanks in advance for any advice?

HTH
Steve
 
G

Ghost

Thanks Matt and Steve,
Your input was very helpfull. I have not done any profiling yet. The
website I am working on consists of JSPs and Servlets that access an
underlying Java server. The Website consists of 3 different frames
that are constantly refreshing (every 30 seconds). Each frame must
access the Java server. I thought each frame was competing for access
to the Java server, but apparently this might not be the problem.

I have been using NetBeans to design new code and view the existing
code. However, the NetBeans Profiler only works with JVM processes.
Do you have any suggestions on how to profile this Website to determine
where the slow-down might be?
 
M

Matt Humphrey

Ghost said:
Thanks Matt and Steve,
Your input was very helpfull. I have not done any profiling yet. The
website I am working on consists of JSPs and Servlets that access an
underlying Java server. The Website consists of 3 different frames
that are constantly refreshing (every 30 seconds). Each frame must
access the Java server. I thought each frame was competing for access
to the Java server, but apparently this might not be the problem.

The constant refreshing could be a problem if you're expecting hundreds or
thousands of requests per minute. If you want to ensure scalability, are
you sure you need to refresh? Perhaps you could have an embedded applet or
JavaScript that polls the server every 30 seconds to first find out if you
need to refresh.
I have been using NetBeans to design new code and view the existing
code. However, the NetBeans Profiler only works with JVM processes.
Do you have any suggestions on how to profile this Website to determine
where the slow-down might be?

Sorry, I'm unfamilier with profiling JSP.

Good luck,
Matt Humphrey (e-mail address removed) http://www.iviz.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top