top | item 36239424

(no title)

devxpy | 2 years ago

Don't use pickle. Use JSON for stuff you can't represent in HTML forms.

For database connections, large datasets, etc (stuff you can't send off to the browser) use redis.

This is a trade-off between DX and UX. Holding session state means you need sticky session routing, and restarting servers kills your user's sessions. Plus imposing a websocket on your users is a cardinal sin, makes scaling incredibly hard, makes page load times abysmal, makes disconnects a nightmare for both you and your user.

Its fine if you're creating something like stable diffusion web ui though, which is meant to be a single user app.

discuss

order

ironmagma|2 years ago

I find these dogmas to be presumptuous. For the use case, Pickle would be fine. Scaling was essentially a non-concern… it was an internal tool behind a VPN and the usage was below a dozen (and at most would have grown to dozens).

JSON is an alright storage format but it can’t do infinity, nan, or many other values important to Python. Also, you would have to write a reifier and serializer for every value. These simply create a problem rather than solving one.

Not optimizing DX would be a mistake when the whole purpose of the project is to improve the DX by allowing the users to not write JS/React. Once the DX starts becoming that cumbersome you might as well just avoid it by switching back to native React.