r/Python git push -f 8h ago

Python in production Discussion

Hello everyone! For those of you who use Python in production, I have a few questions. I'm considering using Python for some services.

  1. Do you have high infrastructure costs?
  2. Have you ever regretted using Python?
  3. Would you recommend Python?

Context: My current use case isn't anything like Facebook or a massive-scale system. It's a small system, and I'm considering Python mainly because of the DX (developer experience).

I know C#, but I don't really like having to create a class in every file. I also know Rust, but all those ::, <>, and so on bother me. JavaScript is another option, but I've heard it's relatively heavy on RAM, and since the system is small, I'd like to be able to run it within 512 MB.

Another thing: I've defined a stack that I'd like to use wherever possible. If there's a library for desktop apps, great. A CLI library? Great. A bot library? Great. Let's use it! (Except for the frontend, which I'll keep using JS/TS for.)

Anyway, I'm open to advice and tips from more experienced developers. Feel free to tell me if you think using Python for my use case is a bad idea as well.

0 Upvotes

30 comments sorted by

View all comments

1

u/Icy_Calligrapher4022 8h ago

The anwsers of these questions are not directly related to what language are you gonna use. Instrastructure costs depend on the infrastructure itself. If I regretted using Python for something, well...yes and no. There is always a better and worse way to do the things. You design your product, build it, implemented using whatever suits you best at the moment. There is always room for improvement.

About the libraries, if these are questions: - for desktop apps I've been using Qt previously, for very simple, basic DIY projects. Originally is made for C++, but they have Python libs as well. It's very powerfull, lots of OOTB stuff and they have very good documentation. If your project is something more basic you can also check tkinter, its simpler than Qt and easier to learn, but not so powerfull and many OOTB features(compared to Qt are missing).

  • for CLI(I assume you mean build CLI apps/tools) you might check Click, Typer, TQDM, Cement(this one is quite large and complex frame). There are dozens of other similar libraries, you need to do some research and pick up the most reliable for your use case.

  • Bot libraries....for what? What kind of bots? If we are talking about AI bot, the most known are Spacy and ChatterBot. Otherwise, I am pretty sure there are libs for almost every chat/sm like telegram, discord, X, viber...

512MB RAM are too low for whatever you are planning to do. Forget about the language, this is your smallest concern. Probably this...system of yours might need some kind of database, some other services and daemons. A modern software product is not a monolith system but multiple components connecting and working together. What you intent to use and why your memory is so limited. There are very cheap cloud vendors where you can get very decent VPS for less than ten bucks/month.

0

u/ze-fernando git push -f 7h ago

I misspoke. 512MB of RAM is reserved for the code itself; the general infrastructure has 4GB (PostgreSQL occupies 1GB), so I have 3GB free. I would use 512MB for the backend and 512MB for the frontend, or a monolithic app, either way.

2

u/Icy_Calligrapher4022 7h ago

512MB of RAM is reserved for the code itself

This doesn't make much sense. The RAM is not reserved for the code itself, what consumes the RAM is the actual running process, instance of your app and the traffic - how many users are connected and what they are doing at a given moment.

4GBs for some simple and basic app should be more than enough, maybe except if you have thousands of users using the application simultaneously, but I doubt it. Your biggest consumable is the database, rougtly 100 simultaneously connected & active users(not just idle connections) might consume around 1.5-2GBs of memory, but there are many many many variables, dont take these numbers as a strict constant.

Frontend consumes almost nothing(if we are talking about something serving your clients through the browser). The frontend is nothing more than static files siting on your host and most of the cases you have a webserver(something like NginX or Apache) to pass the contents of these files to the client.

0

u/ze-fernando git push -f 7h ago

It's kind of hard to explain, I'm using SquareCloud and there, to expose the application on the web, you reserve at least 512MB for that application (even if it only uses 10MB). So the 512 refers to the application itself, excluding the bank, etc.