Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 357429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T12:12:17+00:00 2026-05-12T12:12:17+00:00

I have a text file that I want to send over the network, this

  • 0

I have a text file that I want to send over the network, this file could vary in size from as low as 1KB to 500KB.
What algorithms/techniques could I use to tightly compress this file before sending it such that the least amount of bytes are send over the network and compression ratio is high?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T12:12:17+00:00Added an answer on May 12, 2026 at 12:12 pm

    For compression, I’d consider gzip, bzip2 and LZMA (this is not an exhaustive list but these are IMO the most famous).

    Then, I’d look for some benchmarks on the net and try to gather metrics for various files type (text, binary, mixed) and size (small, big, huge). Even if you’re mostly interested by compression ratio, you might want to look at: the compression ratio, the compression time, the memory footprint, the decompression time.

    According to A Quick Benchmark: Gzip vs. Bzip2 vs. LZMA:

    […] gzip is very fast and has small memory footprint. According to this benchmark, neither bzip2 nor lzma can compete with gzip in terms of speed or memory usage. bzip2 has notably better compression ratio than gzip, which has to be the reason for the popularity of bzip2; it is slower than gzip especially in decompression and uses more memory. However the memory requirements of bzip2 should be nowadays no problem even on older hardware.

    […]

    LZMA clearly has potential to become the third commonly used general purporse compression format on *NIX systems. It mainly competes with bzip2 by offering significantly better compression ratio while still keeping decompressing speed relatively close to that of gzip.

    This is confirmed in LZMA – better than bzip2:

    The description is impressive, in
    short:

    • Better compression ratio (with best compression level when gzip
      achieves 38%, bzip2 34%, LZMA has
      25%).
    • The compression is ratio gain is seen mainly on binary files.
    • Decompress time is much faster (3-4 times) than bzip2.
    • The algorithm allows to be executed in parallel (but the tool
      I’ll describe here is one-thread).

    There are also disadvantages:

    • Compression (excluding lower levels) is much slower than bzip2.
    • Memory requirements are much bigger during compression than bzip2.

    So, for the compression of text files, the same site reports:

    First thing I used LZMA for was
    compressing my mail archive. The spam
    file (mail in mbox format) I chose is
    528MB big and I will use maximum
    compression ratio. During compression
    the lzma process was 370MB big, that’s
    much 🙂 bzip2 was below 7MB. It took
    almost 15 minutes to compress the file
    by lzma and less than 4 minutes by
    bzip2. Compression ration was very
    similar: output file is 373MB for
    bzip2 and 370MB for lzma.
    Decompression time is 1m12s for lzma
    and 1m48s for bzip2.

    Finally, here is another resource with graphical results: Compression Tools: lzma, bzip2 & gzip

    I’d really recommend to perform your own bench (as you’ll be compressing text only and very small to small files) to get real metrics in your environment, but my bet is that LZMA won’t provide a significant advantage on small text files so bzip2 would be a decent choice (even if the time and memory overhead of LZMA might be low on small files).

    If you plan to perform the compression from Java, you’ll find a LZMA implementation here, a bzip2 implementation here (coming from Apache Ant AFAIK), gzip being included in the JDK. If you don’t want to or can’t rely on a third party library, use gzip.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.