Programming: Custom Server in Java

Does anybody here have any experience writing a custom server application in Java?

I’m not talking about a browser-based app as I have basic familiarity with the J2EE framework, JSP, and servlets. I’m interested in writing a standalone transaction server app which communicates in its own protocols, processes its own messages and ultimately uses a database for descisions and transaction storage. So the application would be more similar to writing an http, mail, or ftp server from scratch than creating a web-based app.

The protocols already exist and require support for both IP and serial communications with the ability to support hundreds to thousands of concurrent connections and process dozens or hundreds of transactions per second.

If anybody has had experience in implementing such an application I would appreciate hearing about your experiences.

You may want to check out Java 1.4’s non-blocking IO. Sounds like creating a thread for each server request here will not be possible.

Thanks, I’ve looked at nio some, and I would say that without using nio I couldn’t hit the performance requirements. Do you know if one can use the nio demultiplexer (Selector, I believe) with serial ports. Serial ports aren’t as critical as sockets as I don’t think we have ever needed to work with more than 80 or so serial ports.

What I’m really wondering about is how a large-scale server project like this works with synchronization (the application and implementation will require some shared data) and protocol handling (we have existing protocols which the server must be able to read and write).

Have you written a custom server like this using java? It just seems that it’s not very popular as I haven’t run across much on the net.

Why in java?

If I were doing this (and I have in a few applications), I’d do it on the bare metal with c.

And if java’s your language of choice, why not take advantage of the J2EE framework?

love your nick, btw, np.

Thanks about the nick.

Actually, I really don’t want to do it in Java, but I’ve been assigned to evaluate java for the task. My language of choice is C++ (21st century C++, not MFC-style, I use templates, type-deduction, and procedures with only a couple of classes and no deep hierarchies).

I’ve done it a couple of times before using C++ but this app needs to be multiplatform (Win32 + several *nix). I’m certain I can do it in C++, but I need to evaluate Java anyway.

I’ve already earned my multithreading scars (though the amount that’s unspecified in Java threading scares the crap out of me) and I have the domain experience. What I’m wondering is if Java is suited for this type of app at all, i.e. is Java suited for large-scale development once you can no longer use the classic J2EE architecture, or is it unmanagable?

I’d be very concerned about garbage collection in a performance-critical app. But I’m pretty anti-Java in general, so take that as you will.

And since my handle is more obscure than yours: :stuck_out_tongue:

np_complete wrote

In my estimation, hell no. Especially if this is intended as a long-term, large-scale application. I’ve never heard the terms “java” and “high performance” used in the same sentence, unless it was a discussion of all that’s wrong with the world.

I second the worry about garbage collection. Our software team has been writing a server app in Java, and performance issues are giving us a permanent headache.

Thanks, Sam, Bill, and ultrafilter I’m a little too much of a Java skeptic to begin with and I’d really hoped some Java zealot would chime in saying “Look at XYZcorp: they’ve implemented a heart-lung machine control server using Java in ABCproduct” at which point I would have somewhere else to refer.

Our application domain requires generous hard real time behavior (the value of the answer diminishes for a few seconds and drops to zero after 5 seconds, sometimes after 1 second) but it’s not mission critical (nothing burns down and nobody dies if the response isn’t timely). OTOH I face some terribly strict reliability requirements and the possibility of JVM bugs in addition to RDBMS, OS, hardware bugs, and my own makes me nervous.

If anybody has any good experiences to share wrt Java in a custom server, I’d still be happy to hear from them but I don’t have much hope.

P.S. I read the definition of an ultrafilter 5 times and I’m still pretty sure I don’t understand it :frowning:

It’s simple, really, but probably easier to understand in context. Let’s just hope that Orbifold doesn’t show up; he’s got us both beat handily.

Anyway, you’re unlikely to see too many Java proponents espousing the wonders of Java as a real-time language. Java is good at what it’s good at: it’s cross-platform, and the GUI stuff isn’t too bad (compared to, say, MFC), but it’s just not a real-time systems language.

Sun is working on a real-time Java, btw. I don’t know when it is expected to be released.

You might want to look into C#. It allows you to mix managed and unmanaged code, so you can write a fast kernel for the real-time stuff, and gain the benefits of a managed language for the bulk of the support code.

I like Java quite a bit. It’s a refreshingly clean language compared to C++. There’s a lot to like. But performance isn’t one of them. But bear in mind that there are some large server apps written in Java, so it can be done. You just have to really know what you’re doing and work for it.