This discussion is archived
7 Replies Latest reply: Mar 21, 2011 1:10 AM by 802316 RSS

Efficient serialization

mauric Newbie
Currently Being Moderated
Good morning to all...

I'd like to have some input from you regarding some considerations on serialization mechanism.
I'm currently use serialization to send data via http to a remote server. In a previous post, i received some helpfull inputs regarding best transport practice; now, after experimenting for a while, I'm in doubt if the real bottleneck of the entire process may actually rely on serialization steps.
In fact, I noticed that in the whole communication process (i.e, serialize & compress object on the client, send it over the wire, deserialize on the server side, make some stuff on server side, serialize response on server side and send it to the client, deserialize the response on the client side), the actual time spent in serialization isn' trivial at all.

Of course, default Java serialization performs quite good, but I'm just wondering if there are faster alternatives.
Can anybody help me ?
  • 1. Re: Efficient serialization
    796440 Guru
    Currently Being Moderated
    mauric wrote:
    I'm in doubt if the real bottleneck of the entire process may actually rely on serialization steps.
    So profile it and find out.
  • 2. Re: Efficient serialization
    mauric Newbie
    Currently Being Moderated
    ... well, let's say i'm quite sure after time measurement that the problem may rely on serialization process. Suggestions ?
  • 3. Re: Efficient serialization
    796440 Guru
    Currently Being Moderated
    mauric wrote:
    ... well, let's say i'm quite sure after time measurement that the problem may rely on serialization process. Suggestions ?
    My only suggestion at this point is to actually profile it and come up with actual numbers that show that serialization is an actual bottleneck that is violating actual numerical performance requirements, and then provide enough details about those requirements and the profiling results so that somebody here can offer an appropriate suggestion that's not just a guess.

    Without that, any specific technical solutions that would be suggested would be as likely to be valid as this hypothetical one: I assume that your objects serialized instance variables are all Strings that are English words present in the OED, and you only ever serialize one class, and you know how many Strings it has for member variables (let's say, 4 of them), so you load all the words in the OED into an array on the sender's side and do the same on the receiver's side. The sender has a Map<String, Integer> and the receiver has a Map<Integer, String>. The rest is obvious.
  • 4. Re: Efficient serialization
    mauric Newbie
    Currently Being Moderated
    Hi jverd,

    I agree with you on the fact that without a precise scenario, any suggestion may be a pure hypothesis, like yours, inwhich all data are collections or maps of String objects.

    Now, in my scenario i do actually transfer POJO objects, in which all attributes are basic Java objects like String, Integers, Double. This objects may sent alone, or aggregated in Collections or HashMap. And yes, I often transfer send <code, description> couples aggregate in hashmaps. Generally, none of sent collections reaches more than 50 elements per transfer.

    Anyway, I'd like to emphasize the fact that my question was a general question, and I'd would expect general answers, or opinions, or experiences one could have done. Of course, without circumstantial specification of a particular issue, the most generic answer should be: "It depends." Well, IMHO in a generalist forum, all questions should be general, and answers should be hints more than practical answer... but of course that's my opionion.

    Thank you again !
  • 5. Re: Efficient serialization
    796440 Guru
    Currently Being Moderated
    mauric wrote:
    Anyway, I'd like to emphasize the fact that my question was a general question, and I'd would expect general answers, or opinions, or experiences one could have done.
    Okay, then, here's mine: I do not know of any specific serialization approach that is "faster" or "more efficient" than Java's built-in serialization, but I could invent one in about 2 seconds that would be much, much faster for a specific use-case. So if your question is "Are there faster serialization approaches than Java's built-in one?" then the answer is "Yes." But that Q/A exchange is pointless because, a) That answer has absolutely no practical use, and b) You already knew that answer anyway.
    Well, IMHO in a generalist forum, all questions should be general,
    Rubbish.
  • 6. Re: Efficient serialization
    mauric Newbie
    Currently Being Moderated
    jverd wrote:
    Okay, then, here's mine: I do not know of any specific serialization approach that is "faster" or "more efficient" than Java's built-in serialization, but I could invent >one in about 2 seconds that would be much, much faster for a specific use-case. So if your question is "Are there faster serialization approaches than Java's >built-in one?" then the answer is "Yes." But that Q/A exchange is pointless because, a) That answer has absolutely no practical use, and b) You already knew that >answer anyway.
    Ok. Thank you.
    Rubbish.
    Well,I'd say 'a different opinion', not 'rubbish'.... never mind, anyway.
    Regards!
  • 7. Re: Efficient serialization
    802316 Pro
    Currently Being Moderated
    I can tell you you should be able to make custom, specific use case serialization fast enough that the cost of serialization is trival in the over picture. Super fast deserialization is harder as it generally involves creating new objects.
    Alot depends on how much effort you are willing to put into it.

    Java serialization is for general use and is fast enough for 90%+ of use cases and handles 99% of objects with minimal effort.
    jverd wrote:
    Well, IMHO in a generalist forum, all questions should be general,
    Rubbish.
    Most of the general questions have been asked already and you should be able to search for the general answers with your favourite search engine.
    http://www.google.co.uk/search?q=java+efficient+serialization 823,000 hits.
    Its is hard to imagine that there is many generally questions that haven't been answered already, some a thousand times over.

    This means that fora can only really add the body of existing with more specific questions.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points