Code Monkey home page Code Monkey logo

Comments (1)

nflaig avatar nflaig commented on September 27, 2024 1

Can we do a faster stringify?

There are options like fast-json-stringify which relies on json schema to be defined for the payload. This would work well with Loopback as response schemas should exist for all apis.

I doubt this will help in your case though because it does not improve the performance a lot for large payloads. JSON is just a extremely inefficient serialization format, especially for large payloads.

or maybe make this asynchronous?

There is no cheap way to make JSON serialization async, could run the serialziation in a worker thread but I would assume passing the object and then the serialized json through worker boundaries is quite expensive as well.

I haven't used this library myself, but streaming the serialization via JSONStream might help, likely takes more overall time but you have run the chunks in different iterations of the event loop which will give your app time to respond to other requests.

what happens is that during this time all other requests goes pending in my case liveliness check goes pending and as per my configuration if liveliness failed the container restarts .
how to fix this problem ?

Could just run the server hosting the liveness api in a different thread. That way it would still be able to respond even if main thread is busy.

from loopback-next.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.