Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

performance - Why am I receiving Response code: Non HTTP response code: java.net.SocketException?

I am trying to send requests using JMeter to my application that is running on localhost but many of the requests get failed due to java.net.SocketException. I do not see any exceptions in console though.

I read these question1 and question2 but did not help much.

My code is as following:

 try {
        return myService.findItems(group);

    } catch (NullPointerException n) {
        n.printStackTrace();
    } catch (HibernateException h) {
        h.printStackTrace();
    } catch (IOException i) {
        i.printStackTrace();
    }
    return null;

Repository

  public LinkedHashMap findItems(String group) throws NullPointerException, HibernateException, IOException {
        Session session = sessionFactory.getCurrentSession();
                 ..... //request is sent to database

        return items;
    }

Screen shots of my JMeter configuration

enter image description here

enter image description here

enter image description here

enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

From Screenshots you provided, I think either you thought your system/localhost as super computer or you have mis-configured the jmeter settings.

Screenshot shows, 10000 users/threads will start in 1 second which is completely unreal for application running on a localhost. Jmeter alone will eat most CPU, memory i.e. system resources.

If your Jmeter is eating all resources will your application will get anything (Simple answer is NO) Thus application will go down and you will start getting timeout errors or socket exceptions.

If you have jmeter and application on diff machines then still 10000 users in 1 second is very high load for a normal application and it is obvious that you will face such errors. Try running test with realistic load that is expected for your application with given hw. Maybe 100 users in 1 second and gradually increase them to expected value.

I hope you understood it now :)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...