List of all questions
Total questions: 338
Total unique questions: 251
Python
-
Can we have multiple inheritance in Python? What is the algorithm behind it? (5 times — Digikala, Itoll, Ozone, Snapp (Cabin 1), Zibal)
Answer
Inheritance models an ‘is-a’ relationship and shares behavior via a superclass. Composition models ‘has-a’ and embeds functionality by using other objects. Composition is generally preferred for flexibility and testability.
-
What is decorator? (6 times — 2x Digikala, Exalab, Karnameh, Siz-tel, Sternx)
-
What is the difference between concurrency in python and go? (2 times — Quiz of Kings, Narvan)
-
What is mutable and immutable and why? give me an example for each. (3 times — 2x Exalab, Snapp (Cabin 2))
-
What is generator? when do we use them? do you use them? (2 times — Exalab, Zibal)
Answer
A generator is a function that yields values lazily and returns an iterator. Benefits: low memory usage for large sequences, simple stateful iteration, and easy composition of pipelines. https://realpython.com/introduction-to-python-generators/
-
What is python memory management? (2 times — Narvan, Snappshop)
-
What is the difference between
isand==in Python? (2 times — Snappshop, Zibal)Answer
The
isoperator checks for identity. The==operator checks for equality.a = [1, 2, 3] b = a # b references the same list as a c = a[:] # c is a new list with the same content as a print(a is b) # True, because b is the same object as a print(a is c) # False, because c is a different object print(a == c) # True, because a and c have the same content -
Which function of async in python can run tasks in background? For example we have 4 request and we want send all of it in one time. (1 times — Digikala)
-
What is list comprehension? (1 times — Digikala)
-
What is python data types? and how do you grouping them? (1 times — Exalab)
-
What is coroutine? (1 times — Exalab)
-
What is the difference between set and list? (1 times — Exalab)
-
What is method overriding in python? (1 times — Itoll)
-
What are generators? (1 times — Karnameh)
-
What is GIL? (1 times — Narvan)
-
Compare python with C++. (1 times — Snapp (Cabin 1))
-
Why are we able to change python tuple values even though they are immutable? (1 times — Snapp (Cabin 2))
-
What are the differences between Go and Python? Compare these two languages. (1 times — Snappshop)
-
How does referencing work in Python, and how does it determine when to clean up references? (1 times — Snappshop)
-
How does a Python project (django or fastapi) start up? How is it run from scratch? (1 times — Snappshop)
-
In Python, how does a request reach our service? (1 times — Snappshop)
-
Tell me about Django request life-cycle. (1 times — Toman Pay)
-
Can you tell what is the usage of UWSGI/Gunicorn? (1 times — Toman Pay)
-
Can You tell what are the migration files in django? (1 times — Toman Pay)
-
What is the difference between a
@classmethodand a@staticmethod? When would you use a@classmethod? (1 times — Zibal)Answer
@classmethodreceives the class (cls) and is used for alternative constructors or methods that operate on class-level state.@staticmethodhas no implicit first argument and is used for utility functions grouped with the class without accessing class or instance state. realpython -
How do you create private methods in Python? (1 times — Zibal)
Answer
Use a single leading underscore
_methodto indicate ‘internal’ use (convention). Use double leading underscores__methodfor name-mangling to reduce accidental access from subclasses; note that nothing is truly private. https://www.datacamp.com/tutorial/python-private-methods-explained -
Can you explain Django’s architecture? (1 times — Zibal)
Answer
Django follows an MTV (Model–Template–View) pattern: Models hold data/ORM; Views handle requests; Templates render presentation. Requests flow through middleware, URL routing sends them to views, which use models/templates; Django runs on WSGI/ASGI. https://dev.to/vincenttommi/2-understanding-djangos-architecture-the-mtv-pattern-1gl
-
What are serializers in Django REST Framework (DRF)? (1 times — Zibal)
Answer
Django’s serialization framework provides a mechanism for “translating” Django models into other formats. Usually these other formats will be text-based and used for sending Django data over a wire, but it’s possible for a serializer to handle any format (text-based or not). djangoproject
-
What are custom permissions in DRF and how do you implement them? (1 times — Zibal)
Answer
Custom permissions encapsulate business authorization rules. Implement them by subclassing
rest_framework.permissions.BasePermissionand overridinghas_permissionand/orhas_object_permission, then apply to views or viewsets. https://www.django-rest-framework.org/api-guide/permissions/ -
How can use for example 30 core of cpu in production with python? (1 times — Zibal)
Answer
In Python, you scale CPU usage by running multiple processes, not threads. In production I usually run Uvicorn behind Gunicorn and configure it with one worker per CPU core—so on a 30-core machine, -w 30 lets the app fully utilize all cores.
gunicorn app:app -k uvicorn.workers.UvicornWorker -w 30 -
Explain call by reference & call by value. (4 times — Hamkaran System, MH Holding, 2x Narvan)
-
What is abc? (1 times — Digikala)
-
We have one dictionary and we have a function that change this dictionary. If function dosen’t return anything, our dictionary changed or not? (1 times — Exalab)
-
Difference between list & set? Which one is faster? (1 times — Itoll)
Go
-
What is channel? (3 times — Autoshenas, Ozone, Siz-tel)
-
What is goroutine? (2 times — Quiz of Kings, Siz-tel)
-
How many goroutines can you create(open)? (2 times — Doctoreto, Metazi)
Answer
Millions are possible, limited by memory (heap + per-goroutine stack) and scheduling overhead. GOMAXPROCS controls parallel workers/OS threads (parallelism), not the total goroutine count. Real limit depends on your workload and memory profile. ardanlabs
-
What is OOP concepts that go don’t have it? (2 times — Hamkaran System, Snapp (Cabin 1))
-
What is defer? (2 times — Hamkaran System, Snapp (Cabin 2))
-
We have a scenario that we have a goroutine and this goroutine wait for other goroutine how do you handle it? waitgroup. (2 times — MH Holding, Ozone)
-
What’s difference between goroutine and thread? (1 times — Cloudzy)
Answer
https://www.geeksforgeeks.org/go-language/golang-goroutine-vs-thread/
-
What is the difference between pointer receivers and value receivers in Go? (1 times — Cloudzy)
Answer
https://www.bogotobogo.com/GoLang/GoLang_Receiver_Value_vs_Pointer.php
-
How do you detect memory leaks in Go? (1 times — Cloudzy)
Answer
Using the
pprofpackage to profile memory usage and inspect heap allocations. Observing increasing memory usage over time in long-running programs. Running Go’s race detector(go run -race)to catch goroutine leaks that may indirectly cause memory retention. https://dev.to/gkampitakis/memory-leaks-in-go-3pcn -
What can happen if goroutines are not properly stopped or cleaned up? (1 times — Cloudzy)
Answer
If goroutines aren’t properly stopped, they can leak memory, waste CPU, and potentially cause deadlocks or resource exhaustion in the program.
-
Is there a semaphore concept in Go? (1 times — Doctoreto)
Answer
Go has no built-in semaphore type, but a counting semaphore is commonly implemented with a buffered channel or a small wrapper around sync primitives. sync provides low-level primitives; higher-level concurrency is often done with channels.
-
If you had to implement Go channels from scratch, how would you design them? (1 times — Doctoreto)
Answer
medium
-
How are goroutines blocked and woken up? Who handles that? (1 times — Doctoreto)
Answer
The Go runtime scheduler handles blocking/wakeup. Goroutines are parked when they wait on channels, locks, I/O, timers, or syscalls; the runtime keeps them on wait lists and moves them to runnable queues when the event occurs (timer, channel ready, I/O complete), then schedules them onto OS threads.
-
How can you reduce GC pressure in Go? (1 times — Doctoreto)
Answer
Reduce allocations and object lifetimes: reuse buffers, pool temporary objects, use sync.Pool for short-lived objects, avoid unnecessary boxing/heap escapes, prefer stack/value types when safe, batch work to reuse memory. Measure with pprof and trace before optimizing. victoriametrics
-
What is memory complexity when go tries to put our slice to another (big one)? (1 times — Hamkaran System)
-
What is the difference between strings in Go and C? (1 times — Hamkaran System)
-
What is rune and size? (1 times — Hamkaran System)
-
What is UTf-8 and difference with ASCII? What is 8 mean? What is UTF-16? (1 times — Hamkaran System)
-
What is methods in go? (1 times — Hamkaran System)
-
How do we use the encapsulation concept in Go? (1 times — Hamkaran System)
-
What is garbage collector? (1 times — Hamkaran System)
-
When should we use panic? (3 times — 3x Hamkaran System)
-
We have service out of here that panics somewhere and we don’t want panic here because here is more important imagine something like rocket system how can handle this? (1 times — Hamkaran System)
-
What is
initin Go? How does it work and how does it differ frommain? (1 times — Metazi)Answer
`init()` is a special function: `func init()`. It runs automatically after package-level variables are initialized. You can have multiple `init()`s in a package. You cannot call `init()` yourself. Order: evaluate package vars → run that package’s `init()`s → repeat by dependency order → finally call `main.main()`. `main()` is the program entry point (`package main`, `func main()`) and runs once after all `init()`s finish. -
If you have multiple goroutines that fetch data from different APIs and you want to gather all results and aggregate them, or wait with a timeout then aggregate, how can you do this? (1 times — Metazi)
Answer
package main import ( "fmt" "sync" "time" ) type Result struct { URL string Body string Err error } func fetch(url string) (string, error) { // do actual HTTP call... return "data-for-" + url, nil } func fetchPartial(urls []string, timeout time.Duration) map[string]string { var wg sync.WaitGroup resultsCh := make(chan Result, len(urls)) for _, u := range urls { wg.Add(1) go func(u string) { defer wg.Done() body, err := fetch(u) resultsCh <- Result{URL: u, Body: body, Err: err} }(u) } // close channel when all goroutines are done go func() { wg.Wait() close(resultsCh) }() aggregated := make(map[string]string) timeoutCh := time.After(timeout) Loop: for { select { case r, ok := <-resultsCh: if !ok { break Loop // channel closed, all responses received } if r.Err == nil { aggregated[r.URL] = r.Body } else { // optionally log r.Err } case <-timeoutCh: // timeout occurred — stop waiting for more, but goroutines may still be running. // To avoid leaks in real code, pass a context to requests so they cancel. break Loop } } return aggregated } func main() { urls := []string{"a", "b", "c"} out := fetchPartial(urls, 2*time.Second) fmt.Println(out) } -
How does Go manage goroutines? (1 times — Metazi)
Answer
The runtime scheduler uses three core concepts: G, M, and P.
- G (goroutine): the user-level unit of concurrency (stack, state, metadata). Goroutines are cheap to create and their stacks grow and shrink as needed. - M (machine): an OS thread that actually executes Go code. The runtime creates and reclaims Ms as needed (e.g., to service blocking syscalls). - P (processor): a scheduler context that holds a run queue of runnable Gs and scheduling state. Only an M that has an associated P can run Go code. `GOMAXPROCS` controls how many Ps exist (how many goroutines can run in parallel). How scheduling works (high level): - Each P has a local run queue of runnable goroutines. When a goroutine becomes runnable it’s pushed to a P’s queue. When a P runs out of work it will steal goroutines from other Ps or pull from a global queue; this provides locality and load balancing. - The scheduler chooses a G from a P’s run queue and runs it on the M bound to that P. If that G blocks (channel wait, sleep, blocking syscall), it is parked and another G is scheduled. -
What is generic? (1 times — MH Holding)
-
We have a scenario. We have two goroutine that traverse a slice. One is start from begining and other starts from end. How each goroutine can know other one is in the middle of slice? With cannels. (1 times — MH Holding)
-
What is context in go? (1 times — MH Holding)
-
Is Golang an OOP language? (1 times — Ozone)
-
What is Mutex? (1 times — Ozone)
-
Tell me about go data types. (1 times — Siz-tel)
-
What is difference between channel and connection in rabbitMQ? (1 times — Snappshop)
-
Go doesn’t have classes and is not based on OOP principles. Can you explain that? (1 times — Sternx)
-
What is init function? (1 times — MH Holding)
-
What is a slice, and what is the difference between a slice and an array? (2 times — Hamkaran System, Siz-tel)
-
What is Promise? (1 times — Kharazmi)
-
Waht is stack and differences between heap? (1 times — Hamkaran System)
-
What is
_in imported packages? (1 times — Metazi)Answer
_is the blank identifier. When used in an import likeimport _ "pkg/path"it means: import the package solely for its side effects (package initialization) but do not bind any name to refer to it in the importing file. The compiler won’t complain about an unused import because the blank identifier intentionally discards the package name.import ( _ "github.com/lib/pq" // register pq as a database/sql driver via its init() )(Aside: `_` is also used to discard values in assignments: `_, ok := m["x"]`.) -
Why use it? If there is no need, should we remove it? Why do people still use it? (1 times — Metazi)
Answer
Use them when the package’s
init()performs necessary side effects (driver registration, plugin/handler registration, global initialization). If a package has no needed side effects, remove the import. -
Why write configs in
initinstead ofmain? What are the benefits? What are the problems if we write all code ininitinstead ofmain? (1 times — Metazi)Answer
Pros:
init()runs beforemain(), so it can prepare package-level state.Cons: `init()` cannot accept `context` or return errors, runs during tests, runs before flag/config parsing, and makes shutdown/signal handling hard. Prefer `main()` for orchestration, lifecycle and graceful shutdown. -
Multiple packages each run an
initthatPrintfs the package name. You import them inmain, butmain()is empty. What is the output? (1 times — Metazi)Answer
// pkg/a/a.go package a import "fmt" func init() { fmt.Println("init a") } // pkg/b/b.go package b import "fmt" func init() { fmt.Println("init b") } // main.go package main import ( _ "example.com/project/pkg/a" _ "example.com/project/pkg/b" ) func main() {} // emptyImportant notes about the order: - Initialization (and therefore the `init()` prints) runs before `main()` is called. - The order between packages follows the import dependency graph: if `b` imports `a`, `init a` will always appear before `init b`. - If the packages are independent (neither imports the other), the relative order is unspecified — you should not rely on a particular ordering. - `main()` being empty produces no additional output. Output:init a init b -
Waht is method? (1 times — MH Holding)
-
When you receive a request, how do you read data? How do you unmarshal it? (1 times — MH Holding)
-
What is anonymous function? (1 times — Siz-tel)
-
If we want to know type of var in runtime, how can figure out? (1 times — Siz-tel)
Database
-
How do database index columns work? (5 times — Quiz of Kings, Karnameh, Snapp (Cabin 2), 2x Snappshop)
-
What is ACID? (5 times — 2x Digikala, Karnameh, MH Holding, Zibal)
Answer
https://en.wikipedia.org/wiki/ACID
-
Can you list and explain common database isolation levels and the trade-offs between them? (3 times — Doctoreto, 2x Snappshop)
Answer
geeksforgeeks Wikipedia
-
What is the difference between SQL and NoSQL? (3 times — Exalab, Siz-tel, Snapp (Cabin 2))
-
If our query is slow, how would you optimize it? What is your solution for this problem? (3 times — Hamkaran System, Snappshop, Wallex)
-
If you want to design a database, how do you determine which technologies or approaches to use? (2 times — Quiz of Kings, Digikala)
-
When indexing is bad? (2 times — Snapp (Cabin 2), Snappshop)
-
What is redis datastuctures? (1 times — Quiz of Kings)
-
Suppose we have a queue and a redis and more requests sent to our web server how can handle to redis. redis can handle just a few requests. What’s your approach to handle scale? (1 times — Quiz of Kings)
-
Why you used Postgres in your company? What’s difference between Postgres and MySQL? (1 times — Autoshenas)
-
What is hash table? (1 times — Cloudzy)
Answer
In computer science, a hash table is a data structure that implements an associative array, also called a dictionary or simply map; an associative array is an abstract data type that maps keys to values. A hash table uses a hash function to compute an index, also called a hash code, into an array of buckets or slots, from which the desired value can be found. During lookup, the key is hashed and the resulting hash indicates where the corresponding value is stored. A map implemented by a hash table is called a hash map. wikipedia
-
Suppose we have an application that we sell it to customer. Now we want change the database of that without changing anything on that application because it’s not backward compatible how can we do that? (1 times — DAA)
-
Suppose we have a social media platform, and we want to retrieve all comments of a post. I am using a for statement for this scenario. Is this approach correct? How would you solve this? (1 times — Digikala)
-
If some service failed in microservice or some database broken, which approach can solve that? (1 times — Digikala)
-
What is eventual consistency in the context of databases and distributed systems? (1 times — Doctoreto)
Answer
a replication model where updates will propagate and replicas converge eventually (if no new updates), so reads may be stale briefly but become consistent over time. Practical trade-off: higher availability and latency at the cost of short-term anomalies. Wikipedia
-
What is the difference between WHERE and HAVING in SQL? (1 times — Exalab)
-
Have you experienced with mysql? (1 times — Exalab)
-
Scenario: We have some tables about students, courses and student course. (1 times — Itoll)
-
What is Redis? Why it’s fast? (1 times — Itoll)
-
What are transactions in a database? (1 times — Karnameh)
-
What is NoSql? (1 times — Narvan)
-
mongoDB is a NoSql? (1 times — Narvan)
-
What is LEFT OUTER JOIN? (1 times — Narvan)
-
What is redis data types? (1 times — Siz-tel)
-
What is primary key and foreign key in database? And what’s differences? (1 times — Snapp (Cabin 1))
-
If you have multiple users with the same password, resulting in identical hashes, and you want to ensure that their records in the database are unique, what can you do to make the records unique? (1 times — Snappshop)
-
We have a table with three fields: start time, end time and ID. This is too slow. How do you try to speed it up? (1 times — Snappshop)
-
What is ORM? (1 times — Wallex)
-
Can you example of some tables with one-to-one one-to-many many-to-many many-to-one? (1 times — Wallex)
-
Consider we have some tables and we have fk in each… // TODO (1 times — Wallex)
-
We have a cache for some data in our exchange that we show on the page to users, such as the number of trades, Tether price, etc. When the cached data is cleared, many requests hit the database directly, causing heavy load and potential downtime. How would you fix this problem? (1 times — Wallgold)
Answer
-
Primary Defense: The Mutex Lock with Stale Data Fallback
This is your immediate and most critical fix. It directly stops the herd.
How it works: When the cache for a key is found to be empty or expired, the first request to notice it acquires a distributed lock (e.g., in Redis). Only this request is permitted to query the database.
Handling Subsequent Requests: All other concurrent requests for the same data are not sent to the database. Instead, they have two graceful paths:
Wait Briefly: They can wait for a short, fixed period (e.g., 50-100ms) for the first request to populate the cache.
Serve Stale Data (Preferred): Even better, the system immediately returns the recently expired (“stale”) data while the cache is being refreshed in the background. This provides the best user experience—fast responses with near-real-time data.
-
Proactive Mitigation: Prevent Synchronized Expiration
The thundering herd is often caused by thousands of cache entries expiring at the same moment.
Jitter: Never set a fixed TTL (Time-To-Live). Instead, add a small, random value (±10%) to the expiration time. This spreads cache regeneration naturally over a window of time, preventing a synchronized stampede.
Probabilistic Early Refresh: Before a cache entry officially expires, have a small percentage of requests (e.g., 1%) trigger an early refresh in the background. This “warms” the cache proactively, making it highly likely that a fresh value is already in place before the true expiration time.
-
Architectural Decoupling: Asynchronous Cache Population
For the ultimate resilience, decouple the user request from the cache regeneration process entirely.
How it works: A cache miss never triggers a synchronous database call from a user request. Instead, the system always returns stale data or a default and pushes a “cache refresh task” for that key onto a background job queue (e.g., Redis Queue, SQS, Kafka).
Benefit: User response times become immune to database performance. The background workers can process the refresh tasks at their own pace, and the database load is smoothed out. This is the most robust long-term pattern for high-throughput systems.
-
-
How does Django ORM address the N+1 query problem? (1 times — Zibal)
Answer
Django provides
select_relatedfor single-valued relationships andprefetch_relatedfor many-to-many or reverse relations to eager-load related objects and avoid N+1 queries. You should profile queries and use.values()or annotations when appropriate. https://www.youtube.com/watch?v=zwF5ADW6eKs https://docs.djangoproject.com/en/5.2/topics/db/optimization/https://docs.djangoproject.com/en/5.2/ref/models/querysets/ -
How can you ensure only one instance of your database adapter is created in Python? (1 times — Zibal)
Answer
With singleton pattern
-
What is elasticsearch? (1 times — Autoshenas)
-
Can you write query? (1 times — Narvan)
-
We have two queries that are unrelated to each other. How do you run these and combine their data? Do you run one first and then the other or how? (1 times — Snappshop)
System Design
-
Microservices vs monolotic? How do you choose it when you want to start a project? (2 times — Snapp (Cabin 2), Snapp Market Pro)
-
Waht is event driven architecture? (1 times — Quiz of Kings)
-
We want to design a URL shortener system. How would you design it? (1 times — Quiz of Kings)
-
What is reverse proxy? (1 times — Autoshenas)
-
How can we solve latency between our services in a microservices architecture? How can we protect against data loss? (1 times — Digikala)
-
What is consistency? (1 times — Doctoreto)
Answer
In database systems, consistency (or correctness) refers to the requirement that any given database transaction must change affected data only in allowed ways. Any data written to the database must be valid according to all defined rules, including constraints, cascades, triggers, and any combination thereof. Wikipedia
-
What is a matching engine in an exchange? Explain how it works. (1 times — Netbox)
-
What is CAP theory? (1 times — Snapp (Cabin 2))
-
How do you fix latency in microservices? (1 times — Snapp Market Pro)
-
Imagine a micro-services architecture. we want to follow up a request to have a track of them in the system. How do you suggest to track them. A: My Answer was to add a unique code in the header of the request (1 times — Toman Pay)
-
Writing and inserting data into the matching engine has become a bottleneck and slow for us. How can we solve this? (1 times — Wallex)
-
Suppose we have an e-commerce product (like Digikala) and there’s an issue: when I add one item to my basket, two are added. This happens sometimes. How would you fix this problem? (1 times — Wallgold)
Answer
-
Reproduce & observe
Reproduce in dev with different browsers/devices and slow network.
Capture request traces (client logs, server logs, request IDs, timestamps) and check analytics for patterns (specific browsers, mobile, retries).
-
Identify likely causes
Client: double-click, button not disabled, or UI retry/optimistic update doing a second call.
Network/client library: automatic retry on timeout/resend.
Server: non-idempotent endpoint creating two rows due to race conditions or missing uniqueness constraints.
Message layer: duplicate messages processed twice.
-
Fixes (short & practical)
Client: disable add button after first click and debounce UI actions; show clear loading state.
API: make the operation idempotent — accept an Idempotency-Key (or request id) and store processed keys to ignore duplicates.
DB: enforce correctness with a uniqueness constraint on (cart_id, product_id) and use an atomic upsert to increment quantity, e.g.
-
-
We have two microservices. One of them is very slow and some requests time out without receiving a response. How can the other microservice handle this to avoid being affected? (1 times — Wallgold)
Answer
-
Set a strict downstream timeout and propagate cancellation.
-
Use a circuit breaker to fail fast after repeated timeouts.
-
Retry only idempotent calls with exponential backoff + jitter (limit attempts).
-
Apply bulkheads (separate thread/connection pools) to isolate resources.
-
Provide fallbacks or cached responses where possible.
-
If suitable, make the call async (queue + worker) to decouple user latency.
-
Add metrics/tracing and alert on downstream latency/failure rates.
-
-
-
We have a very large, unstructured log file containing Divar chat data (ranging from gigabytes to terabytes). How would you approach detecting bot activity? (1 times — Wallgold)
Answer
-
Data Parsing and Structuring Reading File: To read a huge file efficiently, stream it in manageable chunks (e.g., several hundred MB at a time) instead of loading it all into memory. Use memory mapping for faster access when possible, and consider distributed or parallel processing frameworks like Apache Spark if you have large-scale infrastructure. Optimize I/O by tuning buffer sizes and, if applicable, store data in compressed or columnar formats to speed selective reads.
Log Parsing: First, I’d parse the unstructured logs into a structured format (e.g., JSON or CSV) by extracting key fields such as timestamp, user ID, message content, IP address, and user agent (if available). This can be done using tools like Apache NiFi for data flow, or custom scripts with regular expressions, but for large-scale data, distributed processing is essential.
-
Feature Engineering (Bot Indicators)
Why: Bots exhibit patterns like bursty activity, repetition, and anomalies vs. human behavior. Key Features (Computed in Spark for scale):
- Frequency: Messages per sender per hour/day (bots send 100x human rates).
- Diversity: Unique receivers per sender (bots spam many).
- Repetition: Message similarity (e.g., Jaccard or Levenshtein distance across a user’s messages).
- Timing: Response latency (bots
-
-
What is middleware? (2 times — MH Holding, Toman Pay)
-
We have a system, and each time we receive an API request, imagine a user gets information. In the result, there are more data. How would you cache that? (1 times — Quiz of Kings)
-
What is DDD? (1 times — Autoshenas)
-
Which tools and mechanisms help keep a system consistent? (1 times — Doctoreto)
Answer
Common techniques: distributed consensus (Raft/Paxos), transactional guarantees (ACID), two-phase commit, idempotency + deduplication, transactional outbox and …
-
If you were given a project with slow loading performance, what steps would you take to improve it? (1 times — Kharazmi)
-
Suppose we used other service that has error how can handle it? (1 times — Hamkaran System)
-
How do you update a user’s feed when they follow or unfollow someone? (1 times — Netbox)
-
Suppose we have sent a request to a service and an action failed. How can we handle other processes to know that the action has failed and handle them accordingly? (1 times — Ozone)
-
We have an API and we want to add new features on it. How can we handle compatibality with older version? v1 v2 (1 times — Snapp (Cabin 2))
-
How can we make sure that the codes you said, are unique? A: My answer was using UUID (1 times — Toman Pay)
-
Ok, we made the requests unique. Where can we store them? (1 times — Toman Pay)
-
Can you tell me the software layers that a request goes through in our code, and where it ends up? (1 times — Wallex)
-
Suppose we want to sent 1 million notification and need request it to db how u handle it? (1 times — Wallex)
-
When do you use a cache? (1 times — Wallex)
-
Suppose we have a lot of requests and the number of our requests has increased. How do you handle this and manage it? (1 times — Wallex)
-
Think we know the problem is from front-end and we don’t want to deploy new version in front and want to fix it for short time in backend how fix it? (1 times — Wallgold)
Answer
-
Fast dedupe/lock in cache (Redis)
Prevent processing the same “add” twice within a short window (2–5s). Build a dedupe key from stable request factors you have today (authenticated user_id or session_id, product_id, and a hash of the request body / headers). Use SET key value NX PX .
-
Make DB operation idempotent/atomic (defensive)
Even with Redis, races or Redis failures can happen. Enforce a DB-level uniqueness + atomic upsert so duplicates can’t create two rows.
-
Optional: Consumer-side dedupe / idempotency store
If your API is queue-based or background-processed, store processed request IDs (or the same dedupe key) for a short TTL and ignore duplicates.
-
Response strategy & UX-friendly behavior
When duplicate is detected in cache, return a harmless success (200) with current cart state — avoids confusing the frontend.
If you detect duplicate after DB upsert, return the updated qty (so frontend can reconcile).
-
Observability & short-term rollout
Add logging/metric (count of dedupe-hits, Redis failures, db-constraint triggers).
Feature-flag the change if possible; otherwise deploy in a safe rollout.
Monitor for false positives (legitimate rapid adds being collapsed) and tune TTL (e.g., 2–5s).
-
Caveats
This is a short-term backend mitigation. It can merge legitimate rapid adds (user intentionally clicks twice quickly) — verify acceptable with product.
Long-term: fix front-end (disable button/debounce + send idempotency key) for best UX.
-
Concurrency
-
What is race condition? (5 times — Quiz of Kings, Hamkaran System, Saraf, 2x Zibal)
Answer
A race condition happens when concurrent operations interleave and produce incorrect state. Solve it with mutual exclusion (mutexes) for in-process protection, transactions, locks (pessimistic or optimistic), atomic DB operations, idempotency, or by redesigning to avoid shared mutable state.
-
What is concurrency and parallelism? (4 times — Digikala, Hamkaran System, MH Holding, Siz-tel)
-
What is the difference between multithread and multiprocess? (1 times — Exalab)
-
Difference between multiprocess and multithread? (1 times — Snapp (Cabin 2))
-
What is the difference between multithreading and concurrency? (1 times — Snappshop)
-
What is the difference between a thread and a process? (1 times — Zibal)
Answer
Threads share a process memory space (lightweight, require synchronization). Processes have separate memory (safer isolation, heavier IPC). Choose threads for shared-memory, processes for isolation.
-
How can send data between processes? (1 times — Hamkaran System)
Networking
-
What is REST? (3 times — Autoshenas, Phanous, Wallex)
-
What does “stateless” mean in the context of REST? (2 times — Autoshenas, DAA)
-
How can link IP to domain in nginx? (2 times — Autoshenas, MH Holding)
-
Are there any APIs that are not stateless? (1 times — Autoshenas)
-
Valid parentheses (1 times — BitPin)
Answer
def check_braces(args: str)-> bool: dic = {'(':')', '[':']', '{':'}'} stack = [] for s in args: if s in dic: stack.append(s) elif stack == [] or dic[stack.pop()] != s: return False return stack == [] -
Answer
def student_gift(nums: list): ans = [1] * len(nums) for i in range(len(nums)): for i in range(1, len(nums)): if nums[i] > nums[i - 1]: if ans[i] > ans[i -1]: continue else: ans[i]+= 1 elif nums[i] < nums[i-1]: if ans[i] < ans[i -1]: continue else: ans[i-1]+=1 for i in range(len(nums) - 1, 0, -1): if nums[i] > nums[i - 1]: if ans[i] > ans[i -1]: continue else: ans[i]+= 1 elif nums[i] < nums[i-1]: if ans[i] < ans[i -1]: continue else: ans[i-1]+=1 return ans students = [18, 14, 10,20] students2 = [i for i in range(1, 15)] students2.reverse() print("test case 1: ", students) result = student_gift(students) print("answer: ", result) print("test case 2: ", students2) result = student_gift(students2) print("answer: ", result) -
What is restful? (1 times — DAA)
-
What is the difference between gRPC and REST? (1 times — Exalab)
-
Game theory question (pirate game) (1 times — Hermes Capital)
-
Tell me about http protocol. (2 times — 2x Karnameh)
-
What is difference between http and https? (1 times — Karnameh)
-
What is http1 and http2 differences? (1 times — Narvan)
-
When type google.com what’s happening? (1 times — Phanous)
-
What is difference between tcp & udp? (2 times — 2x Phanous)
-
What is OSI model? Say name of 7 layers. (1 times — Snapp (Cabin 1))
Algorithms & Data Structures
-
What is hash collision and how do you resolve it? (2 times — Cloudzy, Hamkaran System)
Answer
https://www.youtube.com/watch?v=kNheXzNOcm4&t=251s
-
What is linked list? (2 times — Itoll, MH Holding)
-
What are the time complexities of search, insert, and delete in a linked list? (1 times — Cloudzy)
Answer
Search: O(n) Delete: O(1) Insert: O(1) https://www.bigocheatsheet.com/
-
What is data structure behind map? (1 times — Hamkaran System)
-
Which one is better? linked list or array? (1 times — Itoll)
-
How can delete an item in linked list? (1 times — Itoll)
-
For delete, which one is faster? array or linked list? (1 times — Itoll)
-
What is fastest sorting algorithm? And what’s its time complexity? (1 times — Snapp (Cabin 1))
-
We want to implement a simple token-bucket algorithm in middleware to rate-limit users? (2 times — Saraf, Zibal)
Answer
Run
package main import ( "fmt" "time" ) type User struct { accountID int64 capacity int64 counter int64 refillRate int64 lastRefillTime time.Time } func handler(user User, userData map[int64]User) { if _, ok := userData[user.accountID]; ok { fmt.Println("OK") ud := userData[user.accountID] if ud.counter >= ud.capacity { fmt.Println(ud.counter) panic("rate limit reached") } ud.counter++ fmt.Println(ud.counter) elapsTime := time.Now().Unix() - ud.lastRefillTime.Unix() ud.counter += elapsTime * ud.refillRate } else { u := User{accountID: 123, capacity: 10, counter: 0, refillRate: 1} userData[u.accountID] = u } fmt.Println(user.counter, " ", user.capacity, " ", user.refillRate, " ", user.lastRefillTime) } func main() { userData := make(map[int64]User, 0) newUser := User{accountID: 123, capacity: 10, counter: 0, refillRate: 1, lastRefillTime: time.Now()} for i := range 10 { fmt.Println("i:", i) handler(newUser, userData) } } -
First question (1 times — BitPin)
Answer
in_put = str(input()) res = in_put.split() print(len(res[len(res) - 1])) -
Second question (1 times — BitPin)
Answer
def check_2sum(nums: list, k: int) -> tuple | int: map_ = {} for i in range(len(nums)): map_[nums[i]] = i for i in range(len(nums)): target = k - nums[i] if target in map_ and map_[target] != i: return i + 1, map_[target] + 1 return -1 n, target = map(int, input().split()) nums = list(map(int, input().split())) res = check_2sum(nums, target) if res == -1: print(res) else: print(*res) -
Third question (1 times — BitPin)
Answer
def longest_palindromic_subsequence(s: str) -> int: n = len(s) dp = [[0] * n for _ in range(n)] for i in range(n): dp[i][i] = 1 for length in range(2, n + 1): for i in range(n - length + 1): j = i + length - 1 if s[i] == s[j]: if length == 2: dp[i][j] = 2 else: dp[i][j] = dp[i + 1][j - 1] + 2 else: dp[i][j] = max(dp[i + 1][j], dp[i][j - 1]) return dp[0][n - 1] print(longest_palindromic_subsequence(input())) # Output: 3 # Output: 5 -
We have this menu and there are task & subtasks. How you can traverse all items and access to each? (1 times — Sternx)
-
Math question: The market has reached a state where it has fallen 5 units, then after a while, it rises 1 unit, and this pattern has repeated. How can we predict the market for some time ahead (for example, a month)? How can we assess its probability? Do you have a solution? (1 times — Wallex)
DevOps & Infrastructure
-
What is docker & kober? (6 times — Quiz of Kings, 2x Autoshenas, Phanous, Snapp (Cabin 2), Snappshop)
-
What is the difference between virtual machine and docker? (2 times — Snapp (Cabin 2), Snappshop)
-
What is EXPOSE in docker? (1 times — Autoshenas)
-
Can you build up a project with docker? (1 times — Autoshenas)
-
What is image in docker? (1 times — MH Holding)
-
What is systemD? (1 times — Narvan)
-
How network models in docker? (1 times — Narvan)
-
What features does Linux have that Docker uses for isolated and separate operating systems and for running multiple isolated operating systems? (1 times — Snappshop)
-
How can we know capacity of disk or directory? what command? (1 times — Narvan)
-
What is CI and CD? and the differences? (1 times — Snapp (Cabin 2))
-
The pod is not down, but you have an error (for example, error 500). How do you know where it comes from? (1 times — Snappshop)
-
How do you determine if an application is slow, and how do you measure it? (1 times — Snappshop)
Message Brokers & Queues
-
What is event sourcing and CQRS? (1 times — Autoshenas)
-
When do you use kafka? (1 times — Exalab)
-
What is partition in kafka? (1 times — Exalab)
-
We have two consumers and there are a hundred messages in the queue (RabbitMQ). The first one takes all of them. What should we do so that the second one also receives some? (1 times — Snappshop)
-
What if Our RabbitMQ or Celery Fails? What is your solution not too lose any of the tracking data? (1 times — Toman Pay)
-
What mechanisms do you use to make message processing resilient? (1 times — Doctoreto)
Answer
Transactional outbox
-
How to know how many queues do we need? (I didn’t know the answer!) (1 times — Toman Pay)
Testing
-
You mentioned using BDD, how do you write BDD-style tests? (1 times — Cloudzy)
-
You wrote: “I used Test-Driven Development (TDD) to write tests for critical components, ensuring functional accuracy and improving code quality.” How do tests improve code quality? (1 times — Netbox)
-
Is TDD OK? If I say we don’t need to write tests, what’s your reaction in a team? (1 times — Wallex)
-
You mentioned a simulator bot on your resume. How do you use it to test features and load? (The simulator bot acts like real users to validate functionality and performance.) (1 times — Netbox)
-
Is writing tests good or bad, since there usually isn’t enough time to write them? What’s your opinion? (1 times — Netbox)
Git
-
What is gitflow and workflow? (1 times — Siz-tel)
-
How you fix merge conflict? (1 times — Snappshop)
-
What is difference between git Merge and Rebase? (1 times — Snappshop)
-
What is fast-forward? (1 times — Snappshop)
-
How do you push commits to another branch? (1 times — Zibal)
Answer
cherry-pick
Security & Cryptography
-
What is difference between Authentication and Authorization? (1 times — DAA)
-
Someone tries to login our system with brute force approach. What’s your solution to deal with this problem? (1 times — Phanous)
-
What is the difference between hashing and encryption? (1 times — Snappshop)
-
What is difference between RSA and AES? (1 times — Snappshop)
-
What hashing algorithm do you use? (1 times — Snappshop)
-
When we want to know a user authenticated or not for some action, how know that and how we handle that? (1 times — Wallex)
Design Patterns & SOLID
-
What is SOLID? (4 times — Digikala, Itoll, Snapp (Cabin 2), Wallex)
-
What is polymorphism? (2 times — Itoll, Snapp (Cabin 1))
-
What is MVC? (1 times — Digikala)
-
Which part of MVT that we working with data? (1 times — Digikala)
-
What is singleton? (1 times — Digikala)
-
Can you explain the SOLID principle? (1 times — Kharazmi)
-
What is dependency inversion? (3 times — 3x Wallex)
-
What is object pool? (1 times — Digikala)
-
What is a design pattern, and which design patterns have you used? (7 times — Digikala, Exalab, Itoll, MH Holding, Snapp (Cabin 1), Sternx, Wallex)
-
What is DI? (2 times — Digikala, Zibal)
Answer
Dependency injection supplies an object’s dependencies from the outside (constructor, setter, or factory) rather than creating them internally; this improves testability, decoupling, and configurability.
-
Why do we use a repository layer in a service? (1 times — Zibal)
Answer
A repository abstracts persistence, centralizes queries, and decouples domain logic from storage details — making testing, swapping databases, and enforcing consistency simpler.
OOP
-
What is abstract class? (1 times — Itoll)
-
What is access modifiers? (1 times — Snapp (Cabin 1))
-
What is interface? (3 times — Itoll, MH Holding, Siz-tel)
-
How can create private methods? (1 times — Digikala)
-
What is data binding? How many types does it have? (1 times — Kharazmi)
-
What is update method? (1 times — Karnameh)
-
Write a base class in C++ that name is Animal then create two child classes of it like Dog and Cat and each of these have Eat method but Eat is different in Dog and Cat. And we create some instance of these classes and put them into an array. How can we do that? What is the type of this array? (1 times — Snapp (Cabin 1))
gRPC & Communication
-
What are the main benefits of
gRPC? (2 times — Doctoreto, Narvan)Answer
High performance (HTTP/2 multiplexing), low latency, built-in streaming (client/server/bi-directional), strongly typed contracts via protobuf and code generation, language polyglot support, and built-in interception hooks (auth, load–balancing). Good for microservices and low-latency RPCs.
-
What is RPC? (1 times — Digikala)
Misc
- When you prefer use other packages or write your library? (2 times — 2x Autoshenas)
- What is signal? (1 times — Kharazmi)
- What is eventEmmiter? (1 times — Kharazmi)
- What are guards in Angular? where have you used them? (1 times — Kharazmi)
- What is Angular optimization? (1 times — Kharazmi)
- Have you ever had a weird bug in production even though all your tests passed? How did you fix it? (1 times — Football360)
- We have 2 mindsets in software engineering. One is “tools, languages and stack is not important, you should solve problems regardless of tools.” and the other one is “tools is important and everyone have to solve problems with tools that know them”. Which mindset do you prefer? (1 times — Ozone)