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 8553083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:34:09+00:00 2026-06-11T14:34:09+00:00

Working on the server side of a java based web application (will serve mobile

  • 0

Working on the server side of a java based web application (will serve mobile and web clients) and I need to implement users authentication. In production I have 2 servers (duplicated, working against the same DB) with a load balancer. I used Spring security before so this is the most intuitive way for me but here is my issue:

Spring security authenticates the user once against the DB (when the user logs-in) and later requests are processed and authenticated using a session based token. Now, suppose that one of my production servers is down then I’m loosing my session, meaning the user will get some sort of “unauthorized” response. How can I deal with this?

I thought of 3 options

  1. Use a key-value store such as redis and save my tokens there. If I do that I guess I have to interfere with springs core code – once when user logges in (save the token to the key-value store) and once when authenticating a user (authenticate against this key-value store instead of spring’s in-memory HttpSessionSecurityContextRepository).
  2. Use Spring security in a way that it authenticates users against the DB in every request (I’m not sure it is even possible).
  3. Not using spring security and simply create a filter or some interceptor in order to authenticate each and every request against the DB. This means 2 things: the firsts is that my client will have to apply username and password to each and every request (probably in the header), And second is that I will have to query the DB for each and every request.

So these are my thoughts, I would like to get your insights about those and new suggestions if you have.

  • 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-06-11T14:34:10+00:00Added an answer on June 11, 2026 at 2:34 pm

    How about the state the user maintains across the session?
    If you have such a situation, than you’ll lose the data if the server fails.

    I think the best would be starting with sticky session mechanism here and leaving the authentication as is.

    Sticky session can be configured on the load balancer and usually means the following:

    • Once the use from IP A opens your aplication on server S1 all the subsequent requests will be redirected to this server, but the next user will be automatically connected to server S2 (load balancer will make such a decision). So all-in-all, if you have, say, 10 users working at the same time, 5 of them will be connected to server S1 and the rest to the server B.

    I don’t think that authenticating each request is a good idea (think about web 2, ajax requests) – this will make your server and db highly loaded and as a result it won’t be able to process a lot of users/requests simultaneously.

    Hope this helps

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

Sidebar

Related Questions

I am developing a Spring (Java framework for server-side web-development)web application, which will respond
I'm working on a Java 6 application server which has a web service for
I am working on server side application of FB login. Having converted the example
i've been making web app's and working with various server side language like php,
I'm currently working on my first deployment of a large server side application which
Because I didn't want to implement a communication protocol for my client-server based application,
I am working on a Java web app- it will use GWT for the
Im working in a project.Its server side application is in ofbiz.I want to read,edit,update,etc
I am working on an application which uses tomcat as a web server and
I'm working on a client-side Java application for which I want to create a

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.