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

  • Home
  • SEARCH
  • 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 6343477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:26:44+00:00 2026-05-24T20:26:44+00:00

I have an application that serves artifacts from files (pages from PDF files as

  • 0

I have an application that serves artifacts from files (pages from PDF files as images), the original PDF files live on S3 and they are downloaded to the servers that generate the images when a client hits one of them. These machines have a local caching mechanism that guarantees that each PDF file is downloaded only once.

So, when a client comes with a request give me page 1 of pdf 123.pdf this cache is checked, if there is no pdf file in there, it’s downloaded from S3 and stored at the local cache and then a process generates this page 1 and sends the image back to the client.

The client itself does not know it’s connected to a special server, it all looks like it’s just accessing the website server, but, for the sake of performance I would like to make sure this client is always going to be directed to the same file server that served it’s first request (and downloaded the file from S3).

I could just set a cookie on the client to get him to always download from that specific file server, but placing this on the client leads to unfair usage, as some users are going to open many documents and some are not so I would like to perform this load balancing at the resource level (PDF document).

Each document has a unique identification (integer primary key in the database) and my first solution was using Redis and storing the document id as a key and the value is the host of the server machine that currently has this document cached, but I would like to remove Redis or look for a simpler way to implement this that would not require looking for keys somewhere else.

Also, it would be nice if the defined algorithm or idea would allow for adding more file servers on the fly.

What would be the best way to perform this kind of load balancing with affinity based on resources?

Just for the sake of saying, this app is a mix of Ruby, java and Scala.

  • 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-24T20:26:44+00:00Added an answer on May 24, 2026 at 8:26 pm

    I’d use the following approach in the load balancer:

    • Strip the requested resource URL to remove the query and fragment parts.
    • Turn the stripped URL into a String and take its hashcode.
    • Use the hashcode to select the back end server from the list of available servers; e.g.

      String[] serverNames = ...
      String serverName = serverNames[hash % serverNames.length];
      

    This spreads the load evenly across all servers, and always sends the same request to the same server. If you add more servers, it adjusts itself … though you take a performance hit while the caching warms up again.

    I don’t think you want to aim for “fairness”; i.e. some kind of guarantee that each requests takes roughly the same time. To achieve fairness you need to actively monitor the load on each backend and dispatch according to load. That’s going to (somewhat) negate the caching / affinity, and is going to consume resources to do the measurement and load-balancing decision making. A dumb load spreading approach (e.g. my suggestion) should give you better throughput overall for your use-case.

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

Sidebar

Related Questions

We have an application that installs SQL Server Express from the command line and
I have a client server application that sends XML over TCP/IP from client to
I have a server application that receives information over a network and processes it.
I have a server application that uses a lot of threads. Without wanting to
We have an application that runs over load balanced server instances, and therefore is
We have an application that does single sign-on using a centralized authentication server (CAS).
I have an application that is currently running against a 32-bit SQL Server 2005
I have an application that runs fine when executed off the server. When clients
I have a client/server application that communicates with .Net remoting. I need my clients
We have a Linux server application that is comprised of a number of open-source

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.