Submitted On 01-MAY-1998
aphilips
THIS IS A MAJOR PROBLEM. I HAVE BEEN REQUESTING A FIX FOR THIS SINCE
JDK1.0.X!!! Your that it's too late won't get sympathy from me. Please change
the API so that Server developers can get some relief. I don't know how you
expect full on development without this ability?
Submitted On 26-JUN-1998
HerrmannS
Non-blocking IO is also needed to combine AWT
with listening to a socket.
A good API design should enable the programmer to
register FileEventListeners (either on Java
sockets etc. or concerning native fileDescriptors)
Then the JVM should do an optimized polling, and
create a FileEvent invoking the registered
FileEventListeners, whenever data is available.
This should not interfere with any other activity
namely waiting for and processing AWT-Events.
Controlling the poll in Java is unacceptable
because of performance.
Note that FileEventListeners should be registered
relative to a FileDescriptor because this class
is suitable for generalizing over Java sockets,
native sockets etc.
Finally, Socket needs to make its SocketImpl
accessible (for access to the FileDescriptor)
and it should be possible to create a
FileDescriptor as a wrapper for a socket, opened
by native code.
Submitted On 15-JAN-1999
develcon
As a solution (I have not tried it) you
might use is.available() instead of is.read(),
or set a very short timeout for is.read().
Additionally, if Sun plans to do something about
this in the future, they might consider a
"multi-block" (I forget the academic name) where
a single thread is blocked on multiple read()'s!
For this you really need OS / Hardware events.
Submitted On 05-FEB-1999
ldesmond
I have just hit the same problem. How is Java supposed to work as a server side
solution if there is a limit of 2000 clients per server ?
Very not impressed that this problem has not been mentioned anywhere else.
the .isAvailable works but causes the processor to go mad polling the IO
streams for nothing 99% of the time
Submitted On 22-FEB-1999
Fahad
Start a Java extension package for the solution to this problem... I'm talking
about the javax.* packages... I'm thinking javax.highspeed.* which will be the
foundation for new functionality that uses native libraries to harness the
power of the OS and processor architecture, and in our case the network...
As I'm currently coding a server program, this feature would be extremely
helpful, to the point of dramatically reducing the number of machines we deploy
in our server farm.
Submitted On 25-FEB-1999
dank
Anyone interested in this bug will want to read
http://www.javaworld.com/jw-03-1999/jw-03-volanomark.html
Anyone who still doesn't believe that select()-style
servers are the way to go for high throughput
should probably go have a look at
http://www.acme.com/software/thttpd/benchmarks.html
which shows Java web server performance is
almost two orders of magnitude slower than
C web servers for some tasks.
The client-per-thread model that Sun likes
is certainly good and should be optimized, but
Sun really needs to add a multiple-client-per-thread
ability to the Java platform.
Sun's goal here should be, as Apache says,
to give Java web servers enough performance
that benchmark scores are not a reason to pick
a C web server over a Java web server.
Submitted On 25-FEB-1999
phraktle
In case anyone has code available for using
select() from java (JDK 1.2, WinNT preferably),
pretty please, drop me a mail!
Submitted On 15-MAR-1999
adam@organic.com
I agree that this is a very important issue for
server scalability. I don't think that the
poll()/select() interface is very nice though.
Something like NT CompletionPorts seems better.
Check out the interfaces provided by ACE,
http://www.cs.wustl.edu/~schmidt/ for more
information.
Submitted On 15-MAR-1999
dank
I'm collecting notes about this and
related issues at http://www.kegel.com/c10k.html
I challenge Sun to demonstrate a Java web
server that can handle a fraction of the
punishment that ftp.cdrom.com handles daily.
Submitted On 22-MAR-1999
kW
PLEASE include a fix for this bug pending
for over 26 months in the next MINOR bug fix
release, as we cannot wait until a Java 1.3
appears. I know that this is an API change, but
it's only an extension, it doesn't change
or deprecate old behaviours.
Submitted On 12-APR-1999
garylucas
In some cases, the lack of a poll() method means
that each client connection needs TWO threads
(not just one). One for reading and one
for writing.
Consider the case where a ill-mannered
client might request a high volume of data and
then stop servicing its input socket. The data
flow could back up to the point where any
attempts for the server to write data to the
client blocks. If a single thread were attempting
to write to service multiple clients, one rouge
client (or een well-implemented clients suffering
from network problems) could stop all
data from flowing.
In the current implementation,
the only way to prevent this calamity is to have
a separate thread for each client doing the
writing. Now if we also need a separate
thread to do the reading, we would require
two threads per client.
So the cost of not having a poll() may escalate
even faster than earlier posters claimed.
Submitted On 26-APR-1999
Ray Burns
Like adam@organic.com, I would like to see the notifications tied to completion
of specific I/O requests instead of to a general file "ready" state.
This allows two outstanding requests of the same type on the same file and
simplifies a lot of threading headaches.
Submitted On 07-JUN-1999
Jjesper
I've successfully been using the available()function to find the number of
bytes that can be read without blocking and then reading that number
afterwards. For most purposes I can think of, it is sufficient to poll, say,
once every 1/10th second, so this workaround is usuable in most situations.
Sending data is another matter.
In both cases, Java needs to provide an officially supported path; this is a
very important issue.
Submitted On 10-AUG-1999
bsmith3
I lead an effort to tune an application server which was written entirely in
Java. It was losing a significant amounts of performance to context switching
and stability problems occured as the load was increased. The benefits of using
a Client/Server design with a few threads acting as agents on behalf of many
users was well understood and the architecture was organized accordingly. The
socket layer was a problem even though some of the work-arounds described here
had been tried.
We reimplemented the socket layer using native
methods to interface with Win/NT's I/O completion
port APIs. Maximum throughput doubled and performance degraded gracefully. The
system was stable even with four times the load which had previously been
untenable.
My personal opinion is that this type of interface should be provided from Java
and the APIs should use an agent based mail-box scheme similar to I/O
completion ports. I believe it is a more efficient design than select; however,
I think we can do better in terms of the bookkeeping that is required of the
user. Note, this same technology works very well for handling the large numbers
of files often associated with databases.
Developers shouldn't have to use native methods to get good results.
Bill Smith
Santa Clara Applications Solution Center
Intel Corporation
Submitted On 12-AUG-1999
theferret
There are two issues brought up in this bug.
1. an RFE
2. an implicit BUG REPORT
The fix for the bug report is suggested in the
email.
Have the JVM internally use poll(), instead of
read() directly.
This requires ZERO API changes.
Note the "C code using poll()" vs
"C code not using poll()" results given.
Submitted On 04-SEP-1999
shephara
.isAvailable combined with sleep should work
fine. for writing data, pop a thread
from a thread pool and use it for writing.
this is not really a problem, though I agree
a sugary API would be nice.
Submitted On 07-SEP-1999
xpetos
If a non blocking API is to be developed I would like to
see a general mechanism that can be used by many different
API's to notify the completion of an operation.
In C++ I have used a class AssyncNotifier as a base
class serving as a way of notifing the caller when
the operation has been completed. In Java the java.io
API could be extended so that each operation has a
version of say read() that takes an object of
AssyncNotifier and calls this objects notify() method
whenever the requested operation has been completed.
The read() call would itself return imediately.
Also there must be a mechanism to have one or several
threads to await the notification of several AssyncNotifiers.
This is like the select()/poll() call in UNIX or even more
like the more general WaitForMulipleObjects()
in Win32)
Since the AssyncNotifier would be a general mechanism
each application program could benefit from it and use
it for there own use just like waiting for events like
the reception of character from serial device,
key pressed, disk io completed, socket connected
and so on - all without the need to use one or several threads
for each of these operations.
Submitted On 22-SEP-1999
theferret
using isAvailable() with sleep() is nowhere
near the efficiency of having the
JVM use poll() automatically, instead of
blocking read().
Submitted On 25-SEP-1999
bocio
This is a major bug. How we can develope serious and real server side
applications
with this limit ?
On Digital Alpha JDK the limit is 500 blocking socket and preclude any further
development.
Submitted On 13-OCT-1999
elqabbany
There is a workaround for reading from a socket but no such workaround for
writing to a socket.
For reading, one can simply setSoTimeout() and the read() on the socket's input
stream will timeout in
the given amount of time. This is not elegant, but it will work.
For writing, there is no workaround. OutputStreams don't have any available()
or ready() methods to check if
they're ready for writing. It is not feasible to use another thread if you
have several thousand connections. Even if
I have a dedicated timer thread that interrupts the writing thread after a
given interval, I still don't know how many
bytes were written before timeout. write() should return the number of bytes
written.
Submitted On 18-NOV-1999
knollc
xpetos, You are describing the 'observer pattern' used in several places in the
JDK api.
How about this for a work around: Farm out VM proccesses that will service
client requests.
If 1 VM instance can support 500, 2 can support 1000, etc etc up to the number
of
VM processes that the server can support.
-Chris
Submitted On 19-NOV-1999
enthal
So what about JDK 1.3?? This is a huge problem for high connection volume
server applications. This has gone on too long (your "too late for"
is at the beginning of 98, almost two years ago). Please attend to this in JDK
1.3. Thanks.
Submitted On 29-DEC-1999
ray
Anybody listening there? Time to wake up. It is
rather silly to leave as a last comment that it is
too late for 1.2 and then not even reevaluate it
at 1.3.
This combined with the ongoing lack of things like
generics and const references required for safety
and the recent Sun revelations that Sun was never
committed to standards efforts leave me looking
for a more-open successor to Java.
Submitted On 03-JAN-2000
Morendil
Yoohoo Sun ? This is the 21st century now... JDK 1.3 is just around the bend...
I suppose someone's going to tell us it's "too late to do this in JDK
1.3" ?
Submitted On 07-JAN-2000
gregg@c2-tech.com
This doesn't require API changes, it requires a new class implementation.
Some native code to hide the details is also, obviously needed.
Let's see, I could do this in about 2 days and debug it in another 2 and be
done with it inside of a week. What's the deal SUN?
Submitted On 12-JAN-2000
dkf
I wonder if it is possible to arrange for something like select()
to work on FileDescriptor objects...?
Submitted On 14-JAN-2000
tswain
Poll by looping around InputStream.available()
and read only that many bytes. With select() you don't know which socket had
the
event and you have to parse the FD_SET anyways.
Hope this helps.
Submitted On 18-JAN-2000
warp
With all the frenzy about poll()/select() style of IO, please do not forget
that Java also really really needs NON BLOCKING WRITE() calls.
Submitted On 21-JAN-2000
scsulliv
There's a new JSR which proposes to define
a new set of I/O libraries for the Java platform.
See
http://java.sun.com/aboutJava/communityprocess/jsr/jsr_051_ioapis.html
-Sean
Submitted On 30-JAN-2000
Jjesper
How about setting up a project to implement all of this as native methods using
JNI, with a uniform API across platforms? Has anyone tried this?
Submitted On 25-FEB-2000
jtr
I wonder if the spec will have one callback thread (as in JavaSpaces) or
a thread pool (as in RMI). I'm hoping they will create a thread pool and
give the user some control over it. Hopefully via a factory.
Submitted On 05-MAR-2000
db
Gee, and I was told "will be fixed in 1.3" -- but it's not. Sigh. You'd really think that Sun would be
interested in having "100% Pure Java" _Enterprise Capable_ solutions. I happen to know that this has
affected a number of Sun-internal developers (and projects); gotta wonder why the JVM people aren't
bothering to fix such stuff. I hope it's not that old "we can make threads faster" religion. While it may be
true that the cost of a thread can be reduced, it's NOT true that it can be cut to zero like a select/poll style
API can.
Submitted On 19-APR-2000
dank
Both Sun and HP now support using poll() to some extent to
get around this one-thread-per-client requirement.
For HP, see
http://www.devresource.hp.com/JavaATC/JavaPerfTune/pollapi.html
For Sun, the Solaris J2SE 1.2.2 production release includes
in its example sources a demo of how to use JNI to call
poll.
I'm looking forward to JSR-051 getting started...
Submitted On 25-APR-2000
bestsss
And again. Though available() plus read(upTpAvail) should work for reading (however MS VJM, InputStream
from URL blocks(!) on available) there is nothing about writing. Such API should be implemented, also
InterrupteIOException has enough overhead.
Submitted On 11-MAY-2000
dkf
Dear tswain:
When you are using select() you most certainly can work out
which channel had the event, since the FD sets that you get
passed in indicate which descriptors had the events on. OK,
so this does make the select() syscall one of the most
complex to use correctly, but the info is there, and many
systems use it happily to implement async I/O in
single-threaded processes.
Submitted On 01-JUN-2000
alexcyn
It is really impossible to develop good TCP/IP server
without select() or poll(). I completely agree!
~Alex Cyn
Submitted On 08-JUN-2000
jtr
Mark (the speaker!) didn't show up for this JavaOne BOF (I
left after half an hour). Is this project still on track?
Submitted On 31-JUL-2000
kW
Some OSes implement a /dev/poll device where file descriptors which are ready
(data write completed, data available, error) stream out when reading. This might
be the most convenient an scaleable solution. Now add a method "setEventHandler()" to
every (Socket|File|*)(In|Out)put(Stream|Reader) which is called when the corresponding
file descriptor is ready. THIS would be scaleable.
Submitted On 11-AUG-2000
dkf
No, you use a JavaBeans/JDK-like event observation mechanism
(perhaps a FileEvent class and a add/removeFileListener()
method in Reader, Writer, InputStream, and OutputStream?)
We have the pattern already in use in the language, so
there's no use in introducing a new one...
Submitted On 18-AUG-2000
frankbranch
This becomes an even bigger problem when dealing with Unix
interprocess pipes. The write operations will block if
there is no one listening on the other side of the pipe.
If you are writing a server that uses interprocess pipe to
comunicate to non-java process (one way to integrate to
legacy systems) the server will essentally hang if the
other process dies and is unable to recieve a response.
I have used two extremely poor workaround for this
problem. On is to place the write operation into a
seperate thread that is then interupted by the main thread
after a timeout period has expired. This of course leads
to a whole chorus of exceptions that must be caught in both
the writer thread and the main thread.
The other is two use 2 pipe for every comunication. One
pipe is a signal pipe that must be opened to unblock the
the io open (object contruction) of the writer. The non-
java application must open the signal pipe after it opens
the responce pipe to insure that it is listening. This
insures that a java write operation will have a process
listening on the other side of the pipe 95% of time. It is
possble for the non-java process to open the signal pipe
then die. This leads us back to were we started.
It is extremely important the non-blocking io introduced.
Especial after the Java Connector API JSR16 give us an
intetgration path to legacy system that my include
interprocess pipes.
Submitted On 13-NOV-2000
oznet
This thing is nearly 3 years old... what's the deal?
Submitted On 19-NOV-2000
fancellu
This is pathetic, over 3 years old!
And Sun wonder why we're clamouring for Java to go open
source! To get it out of the arthritic grip of senile
Sun.
3 years?!?!!?! Imagine going to some other vendor,
and getting a 3 year response time on a bug fix, which
is what this is. The bug was that Sun imagined that
Java=pissy little applets. The current IO model simply
doesn't scale to an multi enterprise environment.
Submitted On 05-DEC-2000
satanBug
well.. the promise was to include aysnc IO with 1.3. and
now thats 1.3 is out and has no Async I/O what version do
we wait for? this sux big time
Submitted On 09-DEC-2000
dario1
Guys,
while Sun is working at this
(http://java.sun.com/aboutJava/communityprocess/jsr/jsr_051_
ioapis.html), a partial solution could be
http://www.jrockit.com, a JVM that uses a MxN java-to-
native thread mapping and that promises not to block
threads on I/O.
I found their whitepaper quite interesting.
Regards
Submitted On 21-DEC-2000
gbishop
Please vote to fix this bug. This has been langushing for
too long. Sun needs to submit Java to a standards
organization so things like this get fixed faster.
Submitted On 25-DEC-2000
pinim
Shame on you, Sun. This bug is over 3 years old!!!
And I thought that Microsoft are not responsive...
Submitted On 18-JAN-2001
lapson_lee
It is obviously the worst nightmire that I ever have since
I developed my first server-side java software two years
ago. Sun, it is alreay 3 years old. Shouldn't you fix it on
next version?! Are you listening?!
Submitted On 19-JAN-2001
oznet
Again... what's up with this?
Many years ago I started a project and had to switch to C++
because of this problem. I have specifically NOT been using
Java for the last 3 years because of this limitation and
Sun's lack of support. I've recommended against using Java
on every project I've worked on since, and they listened.
This includes multi-billion dollar government contracts
(some of my original projects).
This request is nearly at the top of the list, as it has
been ever since I can remember. What gives?
Submitted On 19-JAN-2001
yoszu
I'm not 100% sure I'm at the right place, but this has gotten my 3 votes regardless. See I'm from the
FileNotFoundException <- getInputStream() community, where you have trouble getting just one
connection.
What helped me was using HTTPClient in place of the java.net.HttpURLConnection class. Get it at,
http://www.innovation.ch/java/HTTPClient/
Maybe it'll help in some of the other cases here?
For my *much* longer post see "Applets+Plug-in+Proxy=HTTP connect fails" in the Java Plug-in forum at the
JDC
Submitted On 07-FEB-2001
gbishop
This MUST be fixed, who the heck has this been assigned to?
Submitted On 11-FEB-2001
dmbdmb
Please do NOT implement a select style non blocking io. NT
style IOCompletion ports are a much better solution. Please
fix this.
Submitted On 15-FEB-2001
Pavel
Please re-evaluate this issue. It does not involve any API changes.
It only begs for implementing interruptable I/O semantics with existing read/write calls.
IMPORTANT NOTE: Sun's own API included in JVM 1.2+ explicitly relies on I/O in java being interruptable
(see javax.swing.ProgressMonitorInputStream for example).
Interruptable I/O semantics would effectively solve all I/O problems mentioned in comments.
For example, one "watchdog" thread in application would be able to monitor
any number of I/O operations running in separate threads if they select to register themselves
(anonymously, only as Threads)
in the watchdog with simple timeouts or more sophisticated schedules.
Submitted On 22-MAR-2001
paralogic
Its also not quite true that "This requires significant API
changes. It's too late to do this in JDK 1.2" ...
API mods have been suggested since at least 1995
on the networking mailing lists and java user groups.
Submitted On 22-MAR-2001
paralogic
This is a glaring flaw in the class library,
stemming from Sun's continued obstinacy and
insistence that "threads are almost free" - unaddressed
since the first Beta API of Java, which makes Java Servers
with thousands of concurrent connections, almost impossible
to write.
Submitted On 30-MAR-2001
dkf
I've been reading around the subject a bit more (looking at
how other languages handle this in particular) and it seems
that the problem with API changes stems at least in part
from how different the various platforms are on this matter
(Windows is a complete nightmare, particularly when you want
to support everything from NT3.5 and 95 up to 2K, plus
whatever bizarre crud comes out of Redmond in the future,
and this is all due to their not having a properly unified
channel communications API.) Still, the best way I see for
handling this is to have a way of registering callbacks with
readers and writers so code can receive notifications of
when data can be read or written without blocking (there
probably ought to be an error-condition callback as well,
that's a useful one, but you can in practise often overload
that on top of the other two.) This technique is used
extensively in scripting languages (notably Tcl) where it
leads to very small high-capacity servers.
Submitted On 15-MAY-2001
gbishop
YAAAA HOOO!! Thank God! I hope it really is fixed!!!
-G
Submitted On 30-MAY-2001
jtr
Hmmm... it seems partially fixed. I don't see any
asynchronous I/O in the JDK 1.4 beta1, but there is
polling.
Submitted On 01-JUN-2001
hyroo
NOBLOCKING MECHANISM IS ABSOLUTE NEED!!
Submitted On 03-JAN-2002
TOSOI
has no comment
Submitted On 29-JUN-2002
CHUVAK
PING
Submitted On 15-MAY-2003
Rebecca
hey
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|