is serialization really a performance hog?



I'd like to hear the experience of others with object serialization at
high input rates. I implemented Object serialization between a server
and client. It works great, but I'm concerned that serialization
consumes a lot of cpu at high rates. While we load test, I'm thinking
through alternatives. I see two:
1. override Serializable
2. implement Externalizable
Either way, we're going to rewrite some code.

BACKGROUND
The server sends small objects to the clients. The client sends almost
nothing to the server. In the near future the server may transmit 3000
to 5000 small objects per second. I see two potential problems
currently:
A. default serialization is expensive
B. transmission of reference objects along with the small objects

What's a small object? It has 3 to 5 long and String fields.

class SmallObjectWithEventInfo extends AbstractEvent implements
Serializable {
long time = 0;
String label = "label";
long eventId= 0;
long measurement = 0;
String anotherString = "another string";
ContextInfo reference = null;

SmallObjectWithEventInfo(long time, long eventId, long measurement,
ContextInfo context){
this.time = time;
this.eventId=eventId ;
this.measurement = measurement;
this.anotherString = "another string";
reference = context;

label = "Event type "+eventId+ " for "+ context;
}
}

It also has some references to other common objects. In other words,
the small object contains information about a specific event, the
common object describes the context of that event. There are several
contexts, but they are mostly static. These references are handled
transparently for us in Serlializable. Since we only transmit 3 or 4
object types, we can easily override their default serialization.

To implement Externalizable, we would have to send reference objects
separately, then use some unique identifer/lookup like hashcode to
re-associate the reference objects at the client. We already have a
binary protocol in another part of our system so we could easily reuse
that in externalizable. However, my sense is that there are some
hidden gotchas.

QUESTIONS
I'm leaning towards starting with overriding default serialization. If
that doesn't get me enough performance, then I could go for the
reference lookup.
1. Is Java's default Serializable really cpu-intensive/slow? Has anyone
used it at high rates?
2. If you wanted to send 3000-5000 small objects per second, would you
override Serializable, use Externalizable, or something else?
3. Does inheritance complicate serialization?

Thanks

.



Relevant Pages

  • Re: delegate question
    ... information of the method that the delegate is attached to. ... the server, and never get to you (a copy of your client will be sent to the ... event is remoted back to the client, ... the> client-runtime throws serialization exceptions of classes that are not> relevant for my client. ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: "Insufficient state to deserialize the object" error
    ... The delegate itself is a serializable object, so both client and server need ... > that requires serialization? ... >> If any of the assemblies are being loaded from the mapped drive, ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: Copy a remote object localy
    ... > whole object on the SubmitBag() call instead of just sending a proxy. ... > Is there a way to kind of force this serialization? ... >> call to my server object. ... >> client and then to host it on the central server, ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: Client-side vs Server-side objects - how to mix for performance?
    ... Manipulate the data objects on the server using a Manager class. ... There are a few gotchas with shared interfaces, constructors etc so I also recommend his website for up to date information. ... In order to make it more chunky, I want to enable the serialization, transportation of copies of the objects so that I can then inspect the various properties and data of the objects on the client side. ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: Problem with serializing business object instead of core objec
    ... do this since the server does not need to know the type of object I am ... > server assembly and once in the client assembly. ... > client and server assemblies. ... >> an object instead of allowing the framework to handle the serialization so ...
    (microsoft.public.dotnet.framework.remoting)

Loading