Backend возможно Flashcards
Provide few examples of HTTP methods?
content-length, content-type, cookie, authorization, user-agent
What are HTTP status codes?
Расскажи подробнее (выучить самые популярные коды)
HTTP status codes…
From 100 to 199 are reserved for informational status codes.
From 200 to 299 there are success codes
From 300 to 399 there are redirect codes
From 400 to 499 are frontend error codes
From 500 to 599 there are backend error codes
What is proxy?
What is reverse-proxy?
What is difference between them?
Proxy is a server that stands between client and destination server and act on behalf of client.
The purpose of proxy-server can be different.
It can be used to hide real client IP address and another information, or to act like VPN, or just to do some caching in order to improve performance.
The reverse-proxy is a server that stands between server and clients and act on behalf of destination server. It takes requests from clients and then re-send them to real server or servers.
It can be used for multiple purposes. First of all, in order to protect real servers from direct access and improve safety, but it also can be used as traffic balancer and requests router, or, again, be used to cache some data in order to improve performance.
What actions have you personally taken on recent projects to increase maintainability of your code?
Okay… At first, I am trying to keep same code style, because this makes code reading much easier. This was implemented as on my current workplace, same in my pet projects. This touches indentation, naming, etcetera.
Second, is splitting code into small functional blocks, each of what contains only certain information, and I am trying to avoid code mixing, following first SOLID principle.
All in all, I am trying always remember about SOLID and KISS principles and follow them.
What is DNS and what it needed for?
DNS or Domain Name System, is a system used in Internet to transform human-readable domain names, like youtube.com, into IP addresses, which are used by computers for identification and interaction.
What is TDD (Test Driven Development)?
Test Driven Development is a development, where when you want to add new functionality into your application, you write tests, covering this functionality, first, and only then write code for this functionality itself.
This approach makes your code more covered with tests, so it makes it more reliable. Also, when you are writing tests, you have time to think about, for example, what your function should return in what cases, and what are edge cases, etcetera, so this is easier to write man functionality after writing tests.
Explain the difference between mutable and immutable objects. What is an example of an immutable object in JavaScript? What are the pros and cons of immutability? How can you achieve immutability in your own code?
Mutable objects can be changed, while immutable objects is not possible to change.
About pros and cons. From one side, immutability makes states easier to manage, because you are always sure, that if you somewhere used any value, it won’t be accidentally changed somewhere else, and program is more predictable.
From another side, in case of immutability, if you want to somehow modify string, for example, then you create another new object, containing all changes, and this takes additional memory and time.
About how to achieve immutability. For simple things like number or string, we can just use const word when declaring variables with these values. But for more complex things like arrays and objects you need to use special libraries, which provide this immutability functional, or write your own code which will allow you to interact with arrays and objects like if they were immutable too.
What is Domain Driven Design?
Domain Driven Design is a design, where we rely on business processes to define our project structure. The idea is to separate business processes into domains, which are minimally connected to other domains, and then based on these domains needs we create separate project modules, each responsible only for one domain. All data and algorithms needed for each separate domain are placed inside this certain domain module.
What is the difference between a process and a thread within an operating system?
Process is an instance of executable program. This instance includes program code itself, memory, required for code execution, and environment variables. Address space of each process is isolated, so that means that memory that this process uses can’t be directly accessed by other process.
But this isolation and process context itself is quite heavy and requires a lot of resources when creating new one or switching between processes.
Thread is execution unit, that exists inside process scope. Process can have multiple threads that work on its execution. Threads share same resources and address space inside process, and make it possible for process to do some work in parallel, using multiple threads.
To sum up, processes are isolated from each other, but threads share same memory space inside process scope.
Process creation is more complicated and takes more resources that creation of new thread.
Communication between processes is complicated and slow, but threads can communicate quickly.
Errors in one process won’t affect other processes, but error in one thread can crash whole process it belongs to.
Processes are good for things, that should be isolated from each other and be more reliable, while threads are good for splitting process work into multiple parts in order to do it quickly, for example in video redactors.
Как выглядит структура типичного проекта, с которым ты работал?
Ну, сама папка проекта, в ней отдельные папки для api, где лежат прото файлы сервиса, папка с автоматически генерируемым платформой кодом, где всякие базовые штуки, вроде взаимодействия с корпоративным чатом, кроной, кафкой, и всем таким.
Ещё есть отдельная папка для хранения middleware и миграций базы данных.
В отдельной папке также тесты, и ещё код, сгенерированный по прото файлам из самого проекта, и из проектов, которые в специальном файле указаны как связанные с этим проектом. Ну то есть, чтобы можно было туда слать запросы.
Ну и ещё в отдельной папке сам main файл, и внутренний код самого проекта
Как выглядит запрос к RPC ручке?
Ну, обычно это выглядит так, что у тебя есть Golang код, сгенерированный специальной тулзой на базе .proto контракта, и ты вызываешь функции из этого сгенерированного кода.
Как выглядит процесс создания новой RPC ручки?
Ну, сначала описывается сама структура метода в .proto файле сервиса, если надо добавляются новые структуры для описания аргументов или возвращаемого значения.
Потом на базе этого обновляется сгенерированный код.
Потом в функции инициализации там где ты регистрируешь свой сервис который ты ранее определил в .proto файле, ты подставляешь структуру, которая имплементирует методы сервиса.
Ну и в этом методе уже как-то обрабатываешь сам запрос.
Каким образом делали запрос по RPC к другим сервисам?
Ну, у других сервисов есть свои .proto файлы.
В твоём проекте в специальном yaml файле - конфиге для платформы, на которой всё разрабатывается, перечисляются сервисы, с которыми твой сервис взаимодействует.
С помощью тулзы генеришь код, он помещается в специальную папку в проекте, и потом просто используешь функции из этой сгенереной апишки.
Каким образом фронт делал запросы к RPC ручкам?
А фронт не делал запросы к RPC ручкам, фронт ходил на REST ручки, а потом уже с них запросы перенаправлялись куда надо.
Что такое Protocol Buffers, и как они связаны с gRPC?
Protocol Buffers это бинарный формат сериализации данных, который используется в gRPC. То есть, там мы не текст и не JSON какой-нибудь передаём, а в .proto файле определяем контракт, и потом на базе этого .proto файла происходит сериализация и десереализация.